Bearing in mind I don't know perl, in the previous perl script to press the
disconnect button on the Linksys WRT54G router ... do these changes seem
correct to you perl programmers?
-----
1. Log in from Windows to the Linksys WRT54G router with a blank username
and a password of "letmein".
INSTEAD OF:
> my $user='root';
> my $pass='letmein';
I WOULD USE:
my $user='';
$pass='letmein';
-----
2. Navigate to the Linksys WRT54G "Status -> Router" web page.
INSTEAD OF:
> my $adr='https://192.168.0.1/Services.asp'; # talk to this
I WOULD USE:
my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this
-----
3. Press the disconnect button on that Status->Router web page.
INSTEAD OF:
> my $req = HTTP::Request->new(POST => $adr,
> ['action','reboot']);
I WOULD USE:
my $req = HTTP::Request->new(POST => $adr,
['action','disconnect']);
-----
4. Reconnect after a period of time, say 5 seconds.
INSTEAD OF:
my $req = HTTP::Request->new(POST => $adr,
['action','disconnect']);
I WOULD USE:
my $req = HTTP::Request->new(POST => $adr,
----- ['action','connect']);
Since I don't know perl (nor even how to run perl on Windows XP), I wish to
ask before trying to see if the approach seems like it will work for you.
Meanwhile, I'll try to get the script to work (so far, when I click on my
modified script, see below, it just brings up Notepad).
Wilson
#!/usr/bin/perl -w
use strict;
# check out this documentation:
# first, the cookbook
#
http://search.cpan.org/~gaas/libwww-...05/lwpcook.pod
# the LWP reference
#
http://search.cpan.org/~gaas/libwww-...805/lib/LWP.pm
# oh but this is JUST what we want
#
http://lwp.interglacial.com/ch05_05.htm
# my $adr='https://192.168.0.1/Services.asp'; # talk to this
my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this
my $user='';
# my $pass='mypassword';
my $pass='letmein';
# make a User Agent
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
# make a request object
# fill in the button name and value from
# looking at the page source.
# DD-WRT puts out a complicated page with Javascript that
# I don't understand how to deal with, so this doesn't work,
# but in principle (if I knew what to put in for action and reboot)
# it should.
# my $req = HTTP::Request->new(POST => $adr,
# ['action','reboot']);
my $req = HTTP::Request->new(POST => $adr,
['action','disconnect']);
# I need to figure out how to wait 5 seconds in perl; then reconnect
my $req = HTTP::Request->new(POST => $adr,
['action','connect']);
$req->authorization_basic($user, $pass);
# send the request
my $result = $ua->request($req);
# print the result
print $result->as_string;
# The end of a perl script to run on Windows to tell the Linksys WRT54G
# router to disconnect from the ISP; then after 5 seconds, to reconnect.