Re: Script to disconnect Linksys WRT54G wireless router on Windows : Perl
This is a discussion on Re: Script to disconnect Linksys WRT54G wireless router on Windows within the Perl forums in Programming Languages category; 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 ...
![]() |
| | LinkBack | Thread Tools |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
| It's not working yet - but it's closer than it was Here is the tutorial so far. STEP 1: Install ActiveState activeperl freeware on Windows XP http://www.activestate.com/Products/activeperl STEP 2: Modify script to use YOUR password for your Linksys WRT54G router review STEP 3: Run script At this point, I get the following error. I will google for this package and see if I can find it on the web. 501 Protocol scheme 'https' is not supported (Crypt::SSLeay not installed) Content-Type: text/plain Client-Date: Wed, 21 Nov 2007 01:22:38 GMT Client-Warning: Internal response LWP will support https URLs if the Crypt::SSLeay module is installed. More information at <http://www.linpro.no/lwp/libwww-perl/README.SSL>. Wilson #!/usr/bin/perl -w use strict; my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this # my $user='root'; my $user=''; # the Linksys WRT54G wireless router doesn't have login name 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. my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']); sleep 5; 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. |
|
#3
| |||
| |||
| Here is my tutorial to press buttons on your router from the Windows command line. It's not working yet because I don't know how to modify the perl script to load the Win32 OpenSSL package I installed in order to talk to https web site. Does anyone know what line to add to the script below in order to load the Win32 OpenSSL freeware? Wilson ---------------------------------------------------------- How to command your router from the Windows command line: ---------------------------------------------------------- 0. Install ActiveState activeperl freeware on Windows XP http://www.activestate.com/Products/activeperl ---------------------------------------------------------- 1. Install Win32 OpenSSL freeware support for https URLs http://www.openssl.org/related/binaries.html ------------------------------------------------------------ 2. Add the following line to the perl script to load openssl ???? what is the line needed to load Win32 OpenSSL???? ------------------------------------------------------------ 3. Modify the script to press desired buttons on your router #!/usr/bin/perl -w use strict; # Linksys WRT54G Router automation button pressing script # Read the cookbook # http://search.cpan.org/~gaas/libwww-...05/lwpcook.pod # Read the LWP reference # http://search.cpan.org/~gaas/libwww-...805/lib/LWP.pm # Read this too # http://lwp.interglacial.com/ch05_05.htm # my $adr='https://192.168.0.1/Services.asp'; # talk to this router my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this router # my $user='root'; my $user=''; # the Linksys WRT54G wireless router doesn't have login name 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. # my $req = HTTP::Request->new(POST => $adr, ['action','reboot']); # # A view source on the browser web page seems to indicate the disconnect # button is named "disconnect" so I'll substitute that instead of "reboot". my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']); # Wait five seconds and then run the next command sleep 5; 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. |
|
#4
| |||
| |||
| Quoth Wilson <davewilson69@sbcglobal.net>: > It's not working yet - but it's closer than it was > Here is the tutorial so far. > > STEP 1: > Install ActiveState activeperl freeware on Windows XP > http://www.activestate.com/Products/activeperl > > STEP 2: > Modify script to use YOUR password for your Linksys WRT54G router review > > STEP 3: > Run script > > At this point, I get the following error. > I will google for this package and see if I can find it on the web. > > 501 Protocol scheme 'https' is not supported (Crypt::SSLeay not installed) Under ActivePerl you can install Crypt::SSLeay with C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd > #!/usr/bin/perl -w > use strict; use warnings; is better than -w nowadays. > my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this > # my $user='root'; > my $user=''; # the Linksys WRT54G wireless router doesn't have login name > 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. > my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']); Huh? You surely want to do something with this request, like submit it to $ua? Ben |
|
#5
| |||
| |||
| On Wed, 21 Nov 2007 02:08:41 +0000, Ben Morrow wrote: > Under ActivePerl you can install Crypt::SSLeay with > C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd Hi Ben, Your suggestion is very helpful as I was clueless as to the next step. I hope to write up a short tutorial to help others, so, in the spirit of the tutorial, here is the output from your suggested "ppm" command (whatever that is)... I'm not sure what I just did, but a lot happened when I ran: C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd See below for the log file. Wilson Microsoft Windows XP [Version 5.1.2600] (C) Copyright 1985-2001 Microsoft Corp. C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd Syncing site PPM database with .packlists...done Downloading Crypt-SSLeay-0.53...done Unpacking Crypt-SSLeay-0.53...done Generating HTML for Crypt-SSLeay-0.53...done Updating files in site area...done Downloading Crypt-SSLeay-0.53 install script...done Running Crypt-SSLeay-0.53 install script... ************************************************************************** This software package uses strong cryptography, so even if it is created, maintained and distributed from countries where it is legal to do this, it falls under certain export/import and/or use restrictions in some other parts of the world. PLEASE REMEMBER THAT EXPORT/IMPORT AND/OR USE OF STRONG CRYPTOGRAPHY SOFTWARE, PROVIDING CRYPTOGRAPHY HOOKS OR EVEN JUST COMMUNICATING TECHNICAL DETAILS ABOUT CRYPTOGRAPHY SOFTWARE IS ILLEGAL IN SOME PARTS OF THE WORLD. SO, WHEN YOU IMPORT THIS PACKAGE TO YOUR COUNTRY, RE-DISTRIBUTE IT FROM THERE OR EVEN JUST EMAIL TECHNICAL SUGGESTIONS OR EVEN SOURCE PATCHES TO THE AUTHOR OR OTHER PEOPLE YOU ARE STRONGLY ADVISED TO PAY CLOSE ATTENTION TO ANY EXPORT/IMPORT AND/OR USE LAWS WHICH APPLY TO YOU. THE AUTHORS OF OPENSSL ARE NOT LIABLE FOR ANY VIOLATIONS YOU MAKE HERE. SO BE CAREFUL, IT IS YOUR RESPONSIBILITY. CREDIT INFORMATION: This product includes cryptographic software written by Eric A. Young (eay@cryptsoft.com). This product includes software written by Tim J. Hudson (tjh@cryptsoft.com). ************************************************************************** Proceed with installation? [yes] A copy of the needed library ssleay32.dll was found in C:\WINDOWS\system32\ssleay32.dll. If this is compatible with the version (0.9.8a) used to compile the Perl module, all that is needed to complete the installation is to ensure C:\WINDOWS\system32\ssleay32.dll is in your PATH environment variable. Fetch ssleay32.dll? [no] Aborting download of ssleay32.dll. done 13 files installed C:\> |
|
#6
| |||
| |||
| On Wed, 21 Nov 2007 02:08:41 +0000, Ben Morrow wrote: >> my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']); > Huh? You surely want to do something with this request, like submit it > to $ua? Hi Ben, I'm pretty confused about this part as I do not know Perl. The original script I found googling did a "reboot" of the router. I modified that original script to attempt to do a "disconnect" and then five seconds later to do a "connect" (assuming I have the name of the buttons correct for the Linksys WRT54G wireless router). Here is the original script, in its entirety. Does this original script perform "something" with the request? 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 $user='root'; my $pass='mypasswd'; # 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']); $req->authorization_basic($user, $pass); # send the request my $result = $ua->request($req); # print the result print $result->as_string; |
|
#7
| |||
| |||
| Well, I didn't get any results back yet and it's still not working but I'll keep trying things ..... C:\freeware\perl>router.pl 500 Server closed connection without sending any data back Content-Type: text/plain Client-Date: Wed, 21 Nov 2007 06:10:15 GMT Client-Warning: Internal response 500 Server closed connection without sending any data back Here is the tutorial so far ....... (note it doesn't work yet) ...... All I'm trying to do is disconnect and reconnect using a command line script. Any and all help for this tutorial is appreciated as this is my very first perl program ever. Wilson ----------------------------------------------------------------- How to control your wireless router from the Windows command line ----------------------------------------------------------------- 0. Obtain the basic Perl script to reboot the Linksys WRT54G: (see sample Perl script below) ----------------------------------------------------------------- 1. Install ActiveState activeperl freeware on Windows XP: http://www.activestate.com/Products/activeperl For example, install the msi file into c:\freeware\activeperl ----------------------------------------------------------------- 2. Install "Crypt::SSLeay" under ActivePerl using ppm commands: c:\> cd c:\freeware\activeperl c:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd ----------------------------------------------------------------- 3. Install Win32 OpenSSL freeware support for https URLs http://www.openssl.org/related/binaries.html For example, install into c:\freeware\activeperl\win32openssl ----------------------------------------------------------------- 4. Make sure both Perl is in your Windows PATH shell variable: Start » Settings » Control Panel » System » Advanced » Environment Variables » System variables » Path ----------------------------------------------------------------- 5. Test Win32 OpenSSL on Windows from the command line: c:\> openssl version [hit Enter] c:\> openssl s_client -connect www.openssl.org:443 [hit Enter] GET / HTTP/1.0 [hit Enter twice] ----------------------------------------------------------------- 6. Modify this script to press desired buttons on your router #!/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 $user='root'; my $pass='mypasswd'; # 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']); $req->authorization_basic($user, $pass); # send the request my $result = $ua->request($req); # print the result print $result->as_string; ----------------------------------------------------------------- 7. Here is a modified script intended to disconnect & reconnect: #!/usr/bin/perl use strict; use warnings; # 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='root'; my $user=''; # the Linksys WRT54G wireless router doesn't have login name # 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']); # A view source on the browser web page seems to indicate the disconnect # button is named "disconnect" so I'll substitute that instead of "reboot". my $req = HTTP::Request->new(POST => $adr, ['action','disconnect']); # Wait 5 seconds - then reconnect as this will get you a new IP address sleep 5; 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. ----------------------------------------------------------------- ----------------------------------------------------------------- |
|
#8
| |||
| |||
| Any idea how to debug this shortened freeware Perl script to disconnect the Linksys WRT54G wireless router from the ISP? The Perl script just hangs without any output or change in the router. Is there a way to insert debug statements or to step through the Perl code using freeware debuggers on Windows? Here is, I think, the related "view -> source" code on the router at the web page: https://192.168.0.1/StaRouter.htm function ConnStats(obj) { var F=document.status; if(flag == 1){ F.action.value="Connect"; } else{ F.action.value="Disconnect"; } F.submit(); } And, here is the shortened perl script using "Disconnect" as the action: #!/usr/bin/perl -w use strict; my $adr='https://192.168.0.1/StaRouter.htm'; # talk to this router # my $user='root'; my $user=''; # the Linksys WRT54G wireless router doesn't have a username my $pass='LetMeIn'; use LWP::UserAgent; my $ua = LWP::UserAgent->new; my $req = HTTP::Request->new(POST => $adr, ['action','Disconnect']); $req->authorization_basic($user, $pass); # send the request my $result = $ua->request($req); # print the result print $result->as_string; # The end Unfortunately, when I run this router.pl script on Windows, it just hangs. Do you have any suggestions for debugging this on Windows? |
|
#9
| |||
| |||
| I thought the script hung but it just took a while to output this. 500 read failed: Content-Type: text/plain Client-Date: Wed, 21 Nov 2007 13:32:50 GMT Client-Warning: Internal response 500 read failed: Do you have any suggestions for debugging freeware WIndows perl scripts? |
|
#10
| |||
| |||
| [f'ups to clpm] Quoth Wilson <davewilson69@sbcglobal.net>: > On Wed, 21 Nov 2007 02:08:41 +0000, Ben Morrow wrote: > > Under ActivePerl you can install Crypt::SSLeay with > > C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd > > I hope to write up a short tutorial to help others, so, in the spirit of > the tutorial, here is the output from your suggested "ppm" command > (whatever that is)... 'ppm' stands for 'Perl package manager'; it is a utility which comes with ActivePerl for installing Perl modules. If you run it with simply 'ppm' you'll get a GUI you can use to locate and install modules. The reason for the complete URL (rather than simply 'ppm install Crypt-SSLeay') is that ActiveState's repositry is located in Canada, so they aren't allowed to provide cryptographic software without a license. theoryx.uwinnipeg.ca is an alternative repositry which contains the crypto modules most people need. > I'm not sure what I just did, but a lot happened when I ran: > C:\> ppm install http://theoryx5.uwinnipeg.ca/ppms/Crypt-SSLeay.ppd Everything seems to have happened as it should. You can test it has installed correctly with perl -MCrypt::SSLeay -e1 which should give no output. > A copy of the needed library ssleay32.dll was found in > C:\WINDOWS\system32\ssleay32.dll. > If this is compatible with the version (0.9.8a) > used to compile the Perl module, all that is needed to > complete the installation is to ensure > C:\WINDOWS\system32\ssleay32.dll is in your PATH environment variable. This is saying you already have ssleay32.dll on your system. If you want to use this copy instead of downloading a new one, you need to be sure it is the correct version (0.9.8a), which you can probably check from the Properties window in Explorer, and you need to be sure it is in your PATH so perl can find it (system32 is already in your PATH, of course). > Fetch ssleay32.dll? [no] > Aborting download of ssleay32.dll. Here ppm is offering to install a new copy of ssleay32.dll; since you already have one, the default answer is no. Had you said 'yes' it would have downloaded a new copy and put it somewhere perl could find it. > done > 13 files installed The installation was successful. Ben |
![]() |
| Thread Tools | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Can Wireless Gaming Adapter work with Wireless Router? | usenet | DOTNET | 1 | 05-30-2007 03:52 PM |
| Get external (public) IP from my Linksys router | usenet | Java | 2 | 02-03-2005 12:03 PM |
| Win2k ftp, linksys nat router & IE | usenet | Inetserver | 9 | 01-28-2005 03:40 PM |
| Installation issues with linksys router | usenet | DOTNET | 1 | 11-09-2004 05:40 PM |
| email problems since installing a linksys befsx41 router | usenet | Hardware | 0 | 05-18-2004 10:21 PM |


