Hi Monks,
I wrote a perl script to send sms to mobile using mechanize module. But when I tried to run it I am getting following error
Can't call method "value" on an undefined value at D:/Perl64/lib/WWW/Mechanize.pm line 1403.Here is my code for your reference
#!/usr/bin/perl
use WWW::Mechanize;
my $mechObj = WWW::Mechanize->new();
if( scalar(@ARGV) ne 4)
{
help();
}
my $username = $ARGV[0];
my $password = $ARGV[1];
my $recvNo = $ARGV[2];
my $textMsg = $ARGV[3];
$mechObj->get("http://wwwl.way2sms.com/content/index.html");
unless( $mechObj->success() )
{
exit;
}
$mechObj->form_number(1);
$mechObj->field('username', $username);
$mechObj->field('password', $password);
$mechObj->submit_form();
$mechObj->get("http://wwwl.way2sms.com//jsp/InstantSMS.jsp?val=0");
$mechObj->form_number(1);
$mechObj->field("MobNo",$recvNo);
$mechObj->field("textArea",$textMsg);
$mechObj->submit_form();
if($mechObj->success())
{
print "Done \n";
}
else
{
print "Failed \n";
}
sub help
{
print "\nUsage:\n";
print "\tScriptname.pl <user_name> <password> <receiver_name> <msg
+>\n";
exit(0);
}
Please help me to rectify this error
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.