ssinn wrote:
>
> I am currently writing a script that will connect to a URL,
> authenticate itself and GET information to the site.
> I am using this code out of the Perl & LWP book but it is failing.
>
> #!/usr/bin/perl -w
>
> use strict;
> use warnings;
> use LWP;
> use URI;
>
> # This authenticates
> my $browser = LWP::UserAgent->new;
> $browser->credentials(
> 'http://10.1.0.8:80',
> 'index',
> 'test'=>'password'
> );
>
> my $url = 'http://10.1.0.8';
> my $response = $browser->get($url);
> die "Error: ", $response->header('WWW-Authenticate') ||
> 'Error accessing',
> # ('WWW-Authenticate' is the realm-name)
> "\n ", $response->status_line, "\n at $url\n Aborting"
> unless $response->is_success;
>
>
> The error message returned is
>
> Error: Basic realm="index"
> 401 Authorization Required
> at http://10.1.0.8
> Aborting at ./new_push_mac.pl line 18.
>
> What am I doing wrong?
I'm pretty sure the netloc parameter of your call to credentials has the wrong
format: it should just be a host and a port number, and I've never seen it
include the scheme (http) as well. Try like this
$browser->credentials(
'10.1.0.8:80', 'index',
'test', 'password'
);
HTH,
Rob
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/