Perl Script to send Free SMS to any mobile number in INDIA using way2sms
The following script sends SMS to any number in INDIA using the free service provided by Way2Sms.com Requires WWW::Mechanize and Compress::Zlib libraries.
Please remember to fill the username and password in the fields that is mentioned in the script.
Updated code on 28th October 2011. If you face errors use the new script.
#!/usr/bin/perl
use WWW::Mechanize;
use Compress::Zlib;
my $mech = WWW::Mechanize->new();
my $username = ""; #fill in username here
my $keyword = ""; #fill in password here
my $mobile = $ARGV[0];
my $text = $ARGV[1];
$deb = 1;
print length($text)."\n" if($deb);
$text = $text."\n\n\n\n\n" if(length($text) < 135);
$mech->get("http://wwwl.way2sms.com/content/index.html");
unless($mech->success())
{
exit;
}
$dest = $mech->response->content;
print "Fetching...\n" if($deb);
if($mech->response->header("Content-Encoding") eq "gzip")
{
$dest = Compress::Zlib::memGunzip($dest);
$mech->update_html($dest);
}
$dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' name="loginForm"/ig;
$mech->update_html($dest);
$mech->form_with_fields(("username","password"));
$mech->field("username",$username);
$mech->field("password",$keyword);
print "Loggin...\n" if($deb);
$mech->submit_form();
$dest= $mech->response->content;
if($mech->response->header("Content-Encoding") eq "gzip")
{
$dest = Compress::Zlib::memGunzip($dest);
$mech->update_html($dest);
}
$mech->get("http://wwwl.way2sms.com//jsp/InstantSMS.jsp?val=0");
$dest= $mech->response->content;
if($mech->response->header("Content-Encoding") eq "gzip")
{
$dest = Compress::Zlib::memGunzip($dest);
$mech->update_html($dest);
}
print "Sending ... \n" if($deb);
$mech->form_with_fields(("MobNo","textArea"));
$mech->field("MobNo",$mobile);
$mech->field("textArea",$text);
$mech->submit_form();
if($mech->success())
{
print "Done \n" if($deb);
}
else
{
print "Failed \n" if($deb);
exit;
}
$dest = $mech->response->content;
if($mech->response->header("Content-Encoding") eq "gzip")
{
$dest = Compress::Zlib::memGunzip($dest);
#print $dest if($deb);
}
if($dest =~ m/successfully/sig)
{
print "Message sent successfully" if($deb);
}
exit;
#EOF
Usage
./sms.pl mobile number "message"Example:
./sms.pl 9000012345 "Hey there does this work?"
Happy SMSing.
Warning This script is not affiliated or has anything to do with Way2Sms.com. This piece of code is provided AS IS without any warranty. Usage of this script is solely upto you. WAY2SMS will not be happy about you using this script skipping their ads.
:) 02 Dec, 2009
Related Searches
send a text message from linux perl
perl script which fetches output from search api
way2sms authentication with java
t9 dictionary of tata indicom mobile set
apple india macbook 14 price
apple macbook white price in india
working sms script
script brontok remover
perl here document
perl dbi tutorial
send a text message from linux perl
perl script which fetches output from search api
way2sms authentication with java
t9 dictionary of tata indicom mobile set
apple india macbook 14 price
apple macbook white price in india
working sms script
script brontok remover
perl here document
perl dbi tutorial
IRCTC Tatkal ticket booking script required...
Hi,
As of today the way2sms website has changed the div id dynamically using javascript instead of static div id “MobNo”. So we couldnt retrieve that mobile no div id to send sms from this script.
Hence we are getting the error:
There is no form with the requested fields at /usr/bin/sms line 118
Can’t call method “value” on an undefined value at /usr/share/perl5/WWW/Mechanize.pm line 1407.
Solution:
If somebody knows the perl, then they may try to fix this issue, by extracting the javascript function and get the value of the var called “rqMob”. In js, they are storing the dynamically generated div id name into the var rqMob. So once we will get to access this var “rqMob”, then we can just replace the “MobNo” with the value of var “rqMob”
So can anyone help me please......................
changes in Way2sms site
Hi,
Due to the new changes in Way2sms site your may module error out as follows:
Error POSTing http://wwwl.way2sms.com/auth.cl: Not Found:
Change your code as follows to work fine:
< $dest =~ s/<form name="loginForm"/<form action='..\/auth.cl' name="loginForm"/ig;
> $dest =~ s/<form name="loginForm"/<form action='..\/Login1.action' name="loginForm"/ig;
Thanks bhatrix for the patch.
how to use it .. its giving
how to use it .. its giving me as permision denied
chmod +x sms.pl
On Linux? Make sure the file has executable permissions, run chmod +x sms.plthis script works
this script works great......:)).... but is there a way to remove via way2sms.com from our message?????
No, you cant remove the SMS footer
You cant remove that message, as it is added by the way2sms service. :)pls update the script i got
pls update the script i got the following error pls update teh sctipt
6
Fetching...
Loggin...
Sending ...
There is no form with the requested fields at perl.pl line 65
Can't call method "value" on an undefined value at /usr/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1403.
error on 17th Feb 2011 with Updated code on 25th Apr 2010
When sms.pl is executed the following error is appearing...
10
Fetching...
Loggin...
Sending ...
There is no form with the requested fields at sms_original.pl line 65
Can't call method "value" on an undefined value at /usr/lib/perl5/site_perl/5.8.5/WWW/Mechanize.pm line 1403
Please fix this issue...
I think recently some chages are made in way2sms site
way2sms perl script error
Using the latest script but I'm getting the following error
There is no form with the requested fields at sms.pl line 64
Can't call method "value" on an undefined value at /usr/lib/perl5/site_perl/5.8.5/WWW/Mechanize.pm line 1403.
Thanks buddy..........Its working fine......
Hi,
this is cooll..will u please write a script to send sms using 160by2.com
Excellent code.. it works like charm
Hi,
At first it didn't work for me even.
Observed the same errs that are posted here.
It got resolved upon changing url in the perl script
http:/ /wwwl .... to http:/ /wwwo...
It depends on the way2sms servers to which we're re-directed. A million thanks.. man
SMS Gateway URL HTTP SMPP
Send sms via HTTP request, sample url:
Your can use curl function to open url.
http://<span>a</span>dforte.com/jovi.member.app-user-commands?action=send&user=youruser&password=yourpas&phone=+12345678&sender=yourcompany&text=test%20message
can i get the updated script
Can u give the updated script for way2sms sending
Plz check this error msg which i am getting...........
Can't locate object method "update_html" via package "WWW::Mechanize" at C:\way2
sms.pl line 38.
Version of www::mechanize
can you post more details like perl and mechanize version ?Error Status - Dono wat exactly it means
[kiran@localhost Perl]$ ./sms.pl 974xxxx217 "hello how are u"
15
Fetching...
Loggin...
Sending ...
There is no form with the requested fields at ./sms.pl line 65
Can't call method "value" on an undefined value at /usr/lib/perl5/vendor_perl/5.8.8/WWW/Mechanize.pm line 1243.
can you tell me what could be the problem. am using FC8
I have set my selinux to permissive mode..
Updated code
Hi .. The code has been updated to follow the change on way2sms. The script should be working now.I am getting the following
I am getting the following error message.
I hope I don't have any network issues as I am able to send SMS via way2sms
Here is the program output
C:\My Data\personal\Personal>perl sms.pl 9500012345 test
4
Fetching...
Loggin...
Sending ...
There is no form with the requested fields at sms.pl line 65
Can't call method "value" on an undefined value at C:/Perl/lib/WWW/Mechanize.pm
line 1348.
Please help me to get out of this issue.
Error while running the script
Hey, I am getting this error when i try to send a messge
There is no form with the requested fields at ./sms.pl line 65
Can't call method "value" on an undefined value at /usr/share/perl5/vendor_perl/WWW/Mechanize.pm line 1348.
it works
Yes, I have already inform it to my indian friend and he told me that it works! he sends his regards and thanks…
CGI
Hey.. would you consider wrapping this up in a CGI script so it can be deployed on the web? The script works great, BTW.. I'm automating some things with it.
Way2SMS
Way2sms provides a free SMS service and they rely on ads to get the revenue back, deploying this on the web is with CGI would make things too easy for people and destructive for Way2SMS. It is possible to deploy on CGI but I think it would be unethical to do so. :) Consider buying one of the commercial SMS packages if you are using SMS for application, it would be very cheap. The script above is just for personal and educational use only.I'm getting the following
I'm getting the following Error while running the program.
"perl: relocation error: /user/kumark/perl/perl_modules/lib64/perl5/site_perl/5.8.0/auto/HTML/Parser/Parser.so: undefined symbol: Perl_Tstack_sp_ptr"
Can you please help me?.
Try reinstalling PERL
Which OS is this ? On debian like operating systems, useapt-get remove perl apt-get install perl
Thanks a lot for keeping this page updated
Thanks a lot for keeping this page updated
Thanks a lot for keeping this page updated
Thanks a lot for keeping this page updated along with changes in way2sms.com
Hey, I am getting this error
Hey, I am getting this error when i try to send a messge
There is no form with the requested fields at ./sms.pl line 65
Can't call method "value" on an undefined value at /usr/share/perl5/vendor_perl/WWW/Mechanize.pm line 1348.
I think it was a network
I think it was a network problem, it works fine now..
Even i face with the same
Even i face with the same error .. so how to resolve it?
Not receiving sms
Hi,
I tried to run above code from the linux machine. I got below output.
18
Fetching...
Loggin...
Sending ...
Done
Message sent successfully
But i didnt receive the message to my mobile. I would appreciate your help.
DK.
Filled in username and password ?
Hi The script is updated now. Please check if you have filled in your username and password also. Thanks.working fine
Thank you. With the updated script it is working fine,
DK
Mechanize Version?
What version of Mechanize are you runnning ?Getting an Error while running the above code
Hi,
I'm getting the following Error while running the program.
"perl: relocation error: /user/kumark/perl/perl_modules/lib64/perl5/site_perl/5.8.0/auto/HTML/Parser/Parser.so: undefined symbol: Perl_Tstack_sp_ptr"
Can you please help me?.