943,774 Members | Top Members by Rank

Ad:
  • Perl Discussion Thread
  • Unsolved
  • Views: 1012
  • Perl RSS
Jun 22nd, 2009
0

LWP for login to an web application

Expand Post »
Hello friends ,

I have a problem like there is web application and i have to write
a script that should login to the application and then move other parts
of the application

perl Syntax (Toggle Plain Text)
  1. use HTTP::Request::Common qw(POST);
  2. use LWP::UserAgent;
  3. use Data::Dumper;
  4.  
  5. $ua = LWP::UserAgent->new(keep_alive=>1);
  6.  
  7. my $req = POST "http://servername.com:5002/index.php",
  8. ['user_name' => 'username',
  9. 'user_password'=>"password",
  10. 'module'=>'Users',
  11. 'action'=>'Authenticate',
  12. 'return_module'=>'Users',
  13. 'return_action'=>'Login',
  14. ];
  15. my $res = $ua->request($req);
  16. print Dumper(\$res);
  17. if ($res->is_success){
  18. print $res->as_string;
  19. }

when i try this code i am not able to login to the application
it says 302
that is found , but with no data
i want to do like if i post username/password with all required things then it should return the home page of the application

and keep the connection live to move other parts of the application

Thanks
maxj
Last edited by maxjackie; Jun 22nd, 2009 at 3:42 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
maxjackie is offline Offline
1 posts
since Jun 2009
Jul 13th, 2009
0

Re: LWP for login to an web application

try print $res->content; rather then print $res->as_string. The only thing is that, if the post successful then it will retrieve the contents of that whole page as source code (HTML format). you can save the ref. to a string if need be.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
wickedxter is offline Offline
20 posts
since Jul 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Perl Forum Timeline: Connecting to remote server
Next Thread in Perl Forum Timeline: reading a variable in to my script





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC