Thank you very much to all the PerlMonks. I was finally able to figure out how to work around the Javascript problem. As moritz suggested, I recorded the values of encoded_pw and and encoded_pw_unicode (which were being set by Javascript) by logging in once using the browser. I used 'Tamper Data' add-on of Mozilla Firefox to get those values. It is a wonderful tool. Then, I used those values in my program. Here is my final working program:
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use WWW::Mechanize; use HTTP::Cookies; use HTTP::Request::Common qw(POST); #use LWP::Debug qw(+); my $user_name = '...'; my $encoded_pw = urldecode('...'); my $encoded_pw_unicode = urldecode('...'); my $base_url = 'https://courses.northwestern.edu/webapps/login/'; my $target_url = '...'; my $agent = WWW::Mechanize->new( autocheck => 1 ); $agent->cookie_jar(HTTP::Cookies->new); #Get the page once to get the initial cookies and store them #in the cookie jar $agent->get($base_url); die $agent->response->status_line unless $agent->success; my $req = POST $base_url, [ user_id => $user_name, encoded_pw => $encoded_pw, encoded_pw_unicode => $encoded_pw_unicode]; #This POSTs the form and also gets the new cookies and #stores them in the cookie jar $agent->request($req); die $agent->response->status_line unless $agent->success; #Get the desired page my $res = $agent->get($target_url); die $agent->response->status_line unless $agent->success; print $agent->content(); ...

In reply to Re^4: How to login to a form which has Javascript OnSubmit method usirng Perl by ragas
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.