So, I'm writing a little bit of perl for controlling our web-based product (for testing it).

Upon first visit to the url, you get a login page.

To start with, I want to simply post the password to the silly page and get the results. It seems like this should do the trick:
use WWW::Mechanize; print "one\n"; my $mech = WWW::Mechanize->new( agent => 'Mozilla 5.0'); print "two\n" +; my $top = $mech -> get('http://10.0.0.200/'); print "three\n"; print $top->as_string; print "four\n"; print $mech->content; #$mech->set_fields( 'password' => 'secret' ); print "five\n"; #my $response = $mech->submit(); $response = $mech->submit_form( form_name => 'LoginForm', fields => { +password => "thepass" }, button => "Submit" ); print "six\n"; print $response->content;
So, I run it, and I get this:
$ perl testit.pl one two three 500 Can't connect to 10.0.0.200:80 (connect: Operation now in progress +) Content-Type: text/plain Client-Date: Fri, 18 Jul 2008 01:44:21 GMT Client-Warning: Internal response 500 Can't connect to 10.0.0.200:80 (connect: Operation now in progress +) four 500 Can't connect to 10.0.0.200:80 (connect: Operation now in progress +) five There is no form named "LoginForm" at testit.pl line 26 Died at WWW/Mechanize.pm line 1727.
The (mostly) full source of what should have been returned by the first get is here (I'd hoped that the 'readmore' tag would hide this, we'll see if it does or not):
<html> <head> <link rel="shortcut icon" href="/resources/favicon.ico" type="image/x- +icon"> <META http-equiv ....bunch of these ....> <table height="100%" align="center"> <form name="LoginForm" method="post" action="Logon"> <tr> <td> <table class="tableBordered" width="55%" border="0" cellspacing="0" ce +llpadding="5" align="center"> <tr height="15"> <td colspan="5"></td> </tr> <tr height="26"> <td width="10"></td> <td colspan="4" align="left"> <table cellspacing="0" cellpadding="0" > <tr> <td><img src="logon_icon.gif" align="center" width="20" he +ight="20"></td> <td width="10"></td> <td><b>Logon</b></td> </tr> </table> </td> </tr> <tr height="50"> <td width="10"></td> <td nowrap> Password:</td> <td> <input type="password" cols="20" name="password" value="" max +length="15" size="15"></td> <td> <input class="inputButton" type="submit" name="Submit" value= +"OK"></td> <td width="10"></td> </tr> <tr height="20"> <td colspan="5" align="center"></td> </tr> </table> </td> </tr> </form> </table> </body> </html>
By the way - you'll note that I originally tried the 'set_fields' method, but it didn't work either - it complained about 'no form defined'. IF I should have used that, I'd like to know how... So, the question is - why do I seem to be unable to get anything out of the response? Thanks! Rusty

In reply to No response from a get or post???? by rustycar

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.