in reply to Basic authentication with LWP::UserAgent
I'll admit, I'm a bit iffy on the realm thing...I'm assuming your D-link router does HTTP Basic authentication here. To be certain of the realm, use a web-browser to visit the page, and pay attention to the dialogue box that you get. With my browser, I get the string "Please enter username and password for "Realmname"..." — this gives you the realm name you should be using.
Here's my attempt at what you might want... untested, because I don't have access to a D-Link router, and I'm a bit too lazy to set up a webserver with HTTP Basic authentication.
#!/usr/bin/perl use warnings; use strict; use LWP::UserAgent; my $ua = LWP::UserAgent->new(); $ua->credentials("192.168.0.1","192.168.0.1","admin", "password"); my $response = $ua->get("http://192.168.0.1/st_devic.html"); die "Error while getting ", $response->request->uri, " -- ", $response->status_line, "\nAborting" unless $response->is_success; print $response->content, "\n";
3rd Update (yikes!): You want to use the server's location as the first argument to credentials. I missed the different IP addresses when I first read your code.
Update: Apparently I'm confusing Latex commands with HTML entities. Sigh
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Basic authentication with LWP::UserAgent
by abeal (Initiate) on Nov 12, 2003 at 19:07 UTC | |
by davis (Vicar) on Nov 13, 2003 at 09:21 UTC | |
by vek (Prior) on Nov 12, 2003 at 23:31 UTC |