Re: parsing from secure apache site. simple authentication



"aomanchuria" <aomanchuria@xxxxxxxxx> writes:

I need to create a perl script that runs on a local machine. The script
goes to an Apache http site (not https) that has simple authentication.

I assume that by "goes to" you're referring to a retrieving a page with the
LWP module, and by "simple" authentication you mean HTTP's basic auth.

If you meant something else - you should have said so. :-\

Normally you go to the index.htm on the browser, and you get a
username/password challenge window. So the question is, how do I send
my username/password from a text file or some variable in the local
perl scrip. This is the only one thing keeping me from making my script
work.

From "perldoc lwpcook". (Domain changed to .invalid protect the innocent.)

use LWP::UserAgent;
$ua = LWP::UserAgent->new;
$req = HTTP::Request->new(GET => 'http://www.linpro.invalid/secret/');
$req->authorization_basic('aas', 'mypassword');
print $ua->request($req)->as_string;

sherm--

--
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net
.