Of course you can POST any data you like to a HTTP server, with LWP::UserAgent for example, and I'm quite sure WWW::Mechanize allows that as well. Your perl script doesn't hit any button, it just sends data to the server.

All a server does is send data to a user agent - and that data has the form of HTML with embedded javascript - it doesn' t have any kind of control over how the user agent interprets the data.

So all your script has to do is to send the same data as a web browser would do.

If you don't want a general solution, but only one that works for you, there might be shortcut. If you look at that function again:

function validate_form(form) { if ( form.user_id.value == "" || form.password.value == "" ) { alert( "Enter a username and password." ); return false; } //short-cut if challenge/response is disabled. if ( !_useChallenge ) { form.encoded_pw.value = base64encode( form.password.value ); form.encoded_pw_unicode.value = b64_unicode( form.password.value ) +; form.password.value = ""; return true; } ... }

There seems to be a chance that the system accepts login without challenge/response, so all you have to do is to login once manually, and record the the values that are stored in form.encoded_pw_unicode and in the username field, and then uses this data each time you want to log in.


In reply to Re^3: How to login to a form which has Javascript OnSubmit method usirng Perl by moritz
in thread How to login to a form which has Javascript OnSubmit method usirng Perl by ragas

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.