Yes, I was a little tired when I posted this. The modem's output was a bunch of deeply nested tables, which made me go crosseyed, and there was some unneccessary hidden fields.

I woke up this morning and it was obvious what to do. :-) As it turned out, I only needed HTTP::Request

#!/usr/bin/perl use warnings; use strict; use HTTP::Request::Common qw(GET POST); use LWP::UserAgent; my $ua = new LWP::UserAgent(timeout=> 5); #now actually post the form my $request = POST "http://192.168.0.1/login.cgi", [ username => 'myuser@sbcglobal.net', password => 'goombah', ]; my $response = $ua->request($request); my $content = $response->as_string(); #print "$content\n"; #sometimes it asks for the access code, sometimes not if ($content =~ /Access Code Required/){ print "Access Code Required\n"; my $request = POST "http://192.168.0.1/accessLogin.cgi", [ pw0 => 4589235692, #from bottom of modem ]; $response = $ua->request($request); $content = $response->as_string(); print $content; }else {print "sucess\n"}
Once that has been done, I can use a simple get to turn it on and off.
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; my $ua = new LWP::UserAgent; my $request = new HTTP::Request( "GET", "http://192.168.0.1/connect.cg +i?conn=0" ); #conn=1 to connect my $response = $ua->simple_request( $request ); my $contents = $response->content(); print "$contents\n";

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Accessing a DSL modem with LWP by zentara
in thread Accessing a DSL modem with LWP by zentara

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.