Hi All,

I want to access a page that will be available after two POST forms submission, 
clicking two links and then submitting a POST form, using any browser.

But I am stuck at first GET!, using LWP way.

Note: First two forms have same action file 'LOGIN.asp'


### Perl Code ####
#!C:/Perl/bin/perl

use strict;
print "Content-type: text/html\n\n";
use LWP::Debug qw(+);
use LWP::UserAgent;
use HTTP::Cookies;
use HTTP::Request::Common;
use HTTP::Request;
my $myURL       = "http://www.myserver.com/";;
#       FORM 1
my $ua = LWP::UserAgent->new;
$ua->agent("Mozilla 4.2/0.1 " . $ua->agent);
$ua->cookie_jar(HTTP::Cookies->new(file =>'cookie_jar', autosave => 1));
my $r = $ua->simple_request(POST "$myURL/LOGIN.asp",
                            {
                             passwd => 'password',
                             id => 'uid',
                             submit => 'SUBMIT!!'
                            });

my $nIndex      = 0;
while ($r->is_redirect) {
        my $u = $r->header('location') or die "missing location: ", $r->as_string;
   $u    = "$myURL" . $u ;
   print "redirecting to $u\n";
   $r = $ua->simple_request(GET $u);
   $nIndex++;
 }
my $html        = $r->content;


#       FORM 2
my $r2 = $ua->simple_request(POST "$myURL/LOGIN.asp",
                            {
                             passwd => 'password2',
                             id => 'id2',
                             gw => 'kal.aaja',
                             submit => 'SUBMIT!!'
                            });

my $nIndex      = 0;
while ($r2->is_redirect) {
   my $u = $r2->header('location') or die "missing location: ", $r2->as_string;
   $u    = "$myURL" . $u ;
   print "<br>redirecting to $u\n";
   $r2 = $ua->simple_request(GET $u);
   $nIndex++;
 }

my $html2       = $r2->content;

Things go fine upto this line!

But when I add following lines to access a page that will be available by clicking a 
link 
in the IE browser, it keeps running unless i close the Browser.

NOTE: I am using same User Agent object for three requests.


# GET 3
my $req = HTTP::Request->new(GET => 
'$myURL/NewIndex.asp?Whichsite=pendingOrd');

my  $res = $ua->request($req);
print $res->content;
exit;
  # check the outcome
  if ($res->is_success) {
     print $res->content;
  } else {
     print "Error: " . $res->status_line . "\n";
  }  

exit;
-Ahmed.

Reply via email to