Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

problems with LWP & HTTP
Hi

I am trying to log into a secur site using this:

use LWP;
use Crypt::SSLeay;
use HTTP::Request::Common qw(POST);

my $ua = new LWP::UserAgent;




my $req = POST 'https://www.secure.********.com.au/Cardlink/
LoginServlet',
[	'UserID' => '*********',
'Password' => '********',
'Submit' => 'Submit'
];

print $req->as_string;
my $res = $ua->request($req)
print $response->content();

When I run it at the prompt it hangs after printing print $req-
>as_string;

I'm a bit out of my depth.  Anyone know how i can get this to return
the page I am lloking for?


Report this thread to moderator Post Follow-up to this message
Old Post
stephenc
08-15-07 12:03 AM


Re: problems with LWP & HTTP
stephenc wrote:
...
> I am trying to log into a secur site using this:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
>
>
>
> my $req = POST 'https://www.secure.********.com.au/Cardlink/
> LoginServlet',
> 	[	'UserID' => '*********',
> 		'Password' => '********',
> 		'Submit' => 'Submit'
> 	];
>
> print $req->as_string;
> my $res = $ua->request($req)
> print $response->content();
>
> When I run it at the prompt it hangs after printing print $req- 
...

When I try it, your code doesn't even compile.  Please try again, being
sure to copy/paste your code rather than typing it in.

--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl

Report this thread to moderator Post Follow-up to this message
Old Post
Bob Walton
08-15-07 12:03 AM


Re: problems with LWP & HTTP
stephenc wrote:
> Hi
>
> I am trying to log into a secur site using this:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
>
>
>
> my $req = POST 'https://www.secure.********.com.au/Cardlink/
> LoginServlet',
> [ 'UserID' => '*********',
> 'Password' => '********',
> 'Submit' => 'Submit'
> ];
>
> print $req->as_string;
> my $res = $ua->request($req)
> print $response->content();
>
last line should be

print $res->content();

Isn't true?

--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)



Report this thread to moderator Post Follow-up to this message
Old Post
Petr Vileta
08-15-07 03:04 AM


Re: problems with LWP & HTTP
OK, this code does compile but I have had to change my user id and
pasword for obvious reasons:

use LWP;
use Crypt::SSLeay;
use HTTP::Request::Common qw(POST);

my $ua = new LWP::UserAgent;




my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
LoginServlet',
[	'UserID' => 'abshidf',
'Password' => 'oddhfhg',
'Submit' => 'Submit'
];

print $req->as_string;
my $res = $ua->request($req);
print $res->content();

It still hangs!

On Aug 15, 9:55 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> stephenc wrote: 
> 
> 
> 
> 
> 
>
> last line should be
>
> print $res->content();
>
> Isn't true?
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)- Hide quoted text -
>
> - Show quoted text -



Report this thread to moderator Post Follow-up to this message
Old Post
stephenc
08-15-07 09:10 AM


Re: problems with LWP & HTTP
The UserAgent isn't allowing redirection from a POST.  This should fix
the problem.



use LWP;
use Crypt::SSLeay;
use HTTP::Request::Common qw(POST);

my $ua = new LWP::UserAgent;
push @{$ua->requests_redirectable}, 'POST';         #allow redirection
from POST

my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
LoginServlet',
[       'UserID' => 'abshidf',
'Password' => 'oddhfhg',
'Submit' => 'Submit'
];

print $req->as_string;
my $res = $ua->request($req);
print $res->content();

On Aug 15, 1:58 am, stephenc <m...@bymouth.com> wrote:
> OK, this code does compile but I have had to change my user id and
> pasword for obvious reasons:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',
>         [       'UserID' => 'abshidf',
>                 'Password' => 'oddhfhg',
>                 'Submit' => 'Submit'
>         ];
>
> print $req->as_string;
> my $res = $ua->request($req);
> print $res->content();
>
> It still hangs!
>
> On Aug 15, 9:55 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 



Report this thread to moderator Post Follow-up to this message
Old Post
Narthring
08-16-07 12:08 AM


Re: problems with LWP & HTTP
stephenc wrote:
> OK, this code does compile but I have had to change my user id and
> pasword for obvious reasons:
>
> use LWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = new LWP::UserAgent;
>
>
>
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',

Try this script. Maybe this can help you to find reason ;-)

#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;

print "Content-type: text/html\n\n";

# don't forget to set right values in next line
my $params='UserID=abc&Password=abc&Submit=Submit';

my $ua = LWP::UserAgent->new(timeout => 30);
my $req = HTTP::Request->new(POST =>
'https://www.secure.cardlink.com.au/Cardlink/LoginServlet');
$req->headers->header(Accept => '*/*');
$req->headers->header(Connection => "Keep-Alive");
$req->headers->header(Accept_language => "en");
$req->headers->header(Cache_Control => 'no-cache');
$req->content_type('application/x-www-form-urlencoded');
$req->content($params);
my $res = $ua->request($req);
if ($res->code != 200)
{
print "<html><body>Error: ",$res->code," ",$res->message,"<br>",
"Response:<br>",
"<nobr> Message: $res->{_msg}</nobr><br>",
"<nobr> Protocol: $res->{_protocol}</nobr><br>",
"<nobr> Return code: $res->{_rc}</nobr><br>",
"Response headers:<br>";
foreach (sort keys %{$res->{_headers}})
{
print "<nobr> $_: $res->{_headers}->{$_}</nobr><br>";
}
print "<br><br>Page Content:<br>$res->content" if($res->content);
print "</body></html>";
}
else
{
print $res->content;
}


--

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail
from another non-spammer site please.)




Report this thread to moderator Post Follow-up to this message
Old Post
Petr Vileta
08-16-07 12:08 AM


Re: problems with LWP & HTTP
On Aug 16, 1:07 am, "Petr Vileta" <sto...@practisoft.cz> wrote:
> stephenc wrote: 
> 
> 
> 
>
> Try this script. Maybe this can help you to find reason ;-)
>
> #!/usr/bin/perl -w
> use strict;
> use LWP::UserAgent;
>
> print "Content-type: text/html\n\n";
>
> # don't forget to set right values in next line
> my $params='UserID=abc&Password=abc&Submit=Submit';
>
> my $ua = LWP::UserAgent->new(timeout => 30);
> my $req = HTTP::Request->new(POST =>
> 'https://www.secure.cardlink.com.au/Cardlink/LoginServlet');
> $req->headers->header(Accept => '*/*');
> $req->headers->header(Connection => "Keep-Alive");
> $req->headers->header(Accept_language => "en");
> $req->headers->header(Cache_Control => 'no-cache');
> $req->content_type('application/x-www-form-urlencoded');
> $req->content($params);
> my $res = $ua->request($req);
> if ($res->code != 200)
>  {
>  print "<html><body>Error: ",$res->code," ",$res->message,"<br>",
>   "Response:<br>",
>   "<nobr> Message: $res->{_msg}</nobr><br>",
>   "<nobr> Protocol: $res->{_protocol}</nobr><br>",
>   "<nobr> Return code: $res->{_rc}</nobr><br>",
>   "Response headers:<br>";
>  foreach (sort keys %{$res->{_headers}})
>   {
>   print "<nobr> $_: $res->{_headers}->{$_}</nobr><br>";
>   }
>  print "<br><br>Page Content:<br>$res->content" if($res->content);
>  print "</body></html>";
>  }
> else
>  {
>  print $res->content;
>  }
>
> --
>
> Petr Vileta, Czech republic
> (My server rejects all messages from Yahoo and Hotmail. Send me your mail
> from another non-spammer site please.)

I  tried this (having changed the parameters but it still hung at this
point:


C:\eventOrganizerV2>d.pl
Content-type: text/html

I tried enabling cookies and opening the preceding page to see if I
pickedany up but it didn't help.

Any further suggestions?


Report this thread to moderator Post Follow-up to this message
Old Post
stephenc
08-25-07 12:07 AM


Re: problems with LWP & HTTP
On Aug 15, 11:57 pm, Narthring <Narthr...@gmail.com> wrote:
> The UserAgent isn't allowing redirection from a POST.  This should fix
> the problem.
>
> useLWP;
> use Crypt::SSLeay;
> use HTTP::Request::Common qw(POST);
>
> my $ua = newLWP::UserAgent;
> push @{$ua->requests_redirectable}, 'POST';         #allow redirection
> from POST
>
> my $req = POST 'https://www.secure.cardlink.com.au/Cardlink/
> LoginServlet',
>         [       'UserID' => 'abshidf',
>                 'Password' => 'oddhfhg',
>                 'Submit' => 'Submit'
>         ];
>
> print $req->as_string;
> my $res = $ua->request($req);
> print $res->content();
>
> On Aug 15, 1:58 am, stephenc <m...@bymouth.com> wrote:
>
>
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
>
> - Show quoted text -

Hi

I tried that and also enabling cookies and go through the opening page
but it still hangs as the second request.  This is te code:

# clearCard.pl



use strict;
use LWP;
use LWP::UserAgent;
use Crypt::SSLeay;

my $browser = LWP::UserAgent -> new;
push @{$browser->requests_redirectable}, 'POST';
$browser->cookie_jar({});


my $response = $browser -> get ('https://www.secure.cardlink.com.au/
Cardlink/login.jsp');

#print $response->content();
print "to here\n";


$response = $browser -> post (
'https://www.secure.cardlink.com.au/Cardlink/LoginServlet',
[
'UserID' => 'abcgsre',
'Password' => 'hfyretsg',
'Submit' => 'Submit'
],
);

$response->is_success or
die "Login failed: ", $response->status_line, "\n";

#print $response->content();


Any further ideas?


Report this thread to moderator Post Follow-up to this message
Old Post
stephenc
08-28-07 01:24 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Miscellaneous archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:59 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.