funeeldy has asked for the wisdom of the Perl Monks concerning the following question:
Here is my code and debug run. This was working previously, and I cannot get the powers that be to admit that they changed anything. Can anyone tell me what I need to add to this code to make it work again, please???
<code><c></code>
use LWP::Debug qw(+);
use HTML::TokeParser;
use URI;
use Date::Simple (':all');
use LWP::UserAgent;
#use Term::ReadKey;
use LWP 5.64;
use Crypt::SSLeay;
my $browser;
my $realm ='Engineering Private Directory (use your unix p/w)';
my $server = '$URL';
my $port = '80';
my $username = "$username";
my $password = "$passwd";
chomp ($password);
$browser=LWP::UserAgent->new;
$browser->env_proxy;
# Now for the **magic**...
$browser->credentials(
'$url:80',
'Engineering Private Directory \(use your unix p/w\)',
'login' => 'passwd'
);
my $url="$url";
my $req = $browser->get($url);
$req->authorization_basic($username, $password);
my $res = $browser->request($req);
print $res->as_string;
my $response = $browser->get($url);
print "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;
exit;
<code><c></code>
**************************************************************
Debug Output:
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET $URL
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: GET / HTTP/1.0
Host: $HOST
User-Agent: libwww-perl/5.803
LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.1 302 Found
Date: Fri, 16 May 2008 14:10:34 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8e DAV/2 PHP/5.2.6
Location: $URL
Content-Length: 335
Connection: close
Content-Type: text/html; charset=iso-8859-1
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="$URL">here</a>.</p>
<hr>
<address>Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8e DAV/2 PHP/5.2.6 Server at $URL Port 80</address>
</body></html>
LWP::Protocol::http::request: HTTP/1.1 302 Found
LWP::Protocol::collect: read 335 bytes
LWP::UserAgent::request: Simple response: Found
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET $URL
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::http::request: GET / HTTP/1.0
Host: $HOST
User-Agent: libwww-perl/5.803
LWP::Protocol::http::request: reading response
LWP::Protocol::http::request: HTTP/1.1 401 Authorization Required
Date: Fri, 16 May 2008 14:10:37 GMT
Server: Apache/2.2.8 (Unix) mod_ssl/2.2.8 OpenSSL/0.9.8e DAV/2 PHP/5.2.6
WWW-Authenticate: Basic realm="Engineering Private Directory (use your unix p/w)"
Accept-Ranges: bytes
Content-Length: 2968
Connection: close
Content-Type: text/html
LWP::Protocol::http::request: HTTP/1.1 401 Authorization Required
LWP::Protocol::collect: read 2968 bytes
LWP::UserAgent::request: Simple response: Unauthorized
LWP::UserAgent::request: ()
You need a request object, not a HTTP::Response object at trygnats.pl line 48
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LWP::Credentials help with previously working perl script PLEASE???
by pileofrogs (Priest) on May 16, 2008 at 16:24 UTC | |
by funeeldy (Initiate) on May 16, 2008 at 17:37 UTC | |
|
Re: LWP::Credentials help with previously working perl script PLEASE???
by tachyon-II (Chaplain) on May 17, 2008 at 00:29 UTC | |
by funeeldy (Initiate) on May 19, 2008 at 14:15 UTC | |
by tachyon-II (Chaplain) on May 19, 2008 at 15:40 UTC |