in reply to Re: how to reboot adsl modem with perl?
in thread how to reboot adsl modem with perl?

Hi Fletch, Martin, Thanks for providing me somewhere to start. Hope my newbie perl skill will be enough to do the job :)
  • Comment on Re^2: how to reboot adsl modem with perl?

Replies are listed 'Best First'.
Re^3: how to reboot adsl modem with perl?
by marto (Cardinal) on Feb 23, 2007 at 09:12 UTC
    No problem MelaOS,

    if you do have any problems post your code, a description of the problem along with the error message, and the kind monks will reply with advice.

    Martin
      Hi Martin, Great, that's because so far i'm kind of stuck :(
      After browsing through some simple tutorial this is what i came up with.

      use WWW::Mechanize; my $mech = WWW::Mechanize->new( autocheck => 1 ); # connect to the adsl setting page $mech->get( "http://192.168.1.1" ); # connect with user name and password my $r = $mech->submit_form( form_number => 2, fields => 'uiViewUserName' => "admin", 'uiViewPassword' => "admin"); die "Couldn't submit form" unless $r->ls_success; # print the content of the admin page so that i know i'm in #print $mech->content;

      I've try other methods like $mech->field, $mech->set_visible but i always get this error back.
      Error GETing http://192.168.1.1: Can't connect to 192.168.1.1:80 (connect: Unknown error) at C:\Documents and Settings\Mela\Desktop\simple.pl line 4
      and included is the html content for that admin page that i get by using $mech->get( "http://192.168.1.1", ":content_file" => "C:\output.txt" );

      Basically i just want the script to login, check if the status is disconnected or then proceed to reboot the router.
      Any advice on what am i doing wrong here?
        Hi MelaOS,

        Excuse the delay in my reply. I notice a couple of things, you can use WWW::Mechanize to save the content, but not work with it. Secondly this page seems to use a lot of JavaScript (yuck! :P). Now the WWW::Mechanize documentation states:

        "Please note that Mech does NOT support JavaScript. Please check the FAQ in WWW::Mechanize::FAQ for more."

        And the first thing that happens when that page is loaded is that a JavaScript function uiDoOnLoad is called. Take a look at the code to see what it does.

        All is not lost, the modules Win32::IE::Mechanize and Mozilla::Mechanize provide a WWW::Mechanize style interface for automating Internet Explorer and Mozilla respectively. You could use either of these, which do support JavaScript, the same way that you are using WWW::Mechanize (be sure to read the documentation of the module you choose to use), to achieve this task.

        If you have any more problems let us know.

        Cheers,

        Martin