Gossamer Forum
Home : General : Perl Programming :

How can I get a file that in protect password area?

Quote Reply
How can I get a file that in protect password area?
Hi all,

I try with this code:
use LWP::Simple;
$netloc = "http://username:password\@www.server.com/data/data.db";
print "Content-Type: text/plain\n\n";
$content = get($netloc);
print $content;

But I can not get any thing although the file data.db exists.

I would appreciate any helps.

Thanks in advance,

Beck
Quote Reply
Re: [Beck] How can I get a file that in protect password area? In reply to
Do you have ftp access to the site?
Quote Reply
Re: [Beck] How can I get a file that in protect password area? In reply to
You will have to use LWP::UserAgent instead of LWP::Simple. You can then specify more headers, like so:

use LWP::UserAgent;
$ua = new LWP::UserAgent;
$req = new HTTP::Request GET => 'http://www.server.com/secret/';
$req->authorization_basic('username', 'password');
print $ua->request($req)->as_string;

Hope this helps.

Wil

- wil
Quote Reply
Re: [Beck] How can I get a file that in protect password area? In reply to
You can read the full range of methods here:

http://www.perldoc.com/...b/LWP/UserAgent.html

Last edited by:

RedRum: Oct 8, 2001, 7:31 AM
Quote Reply
Re: [Wil] How can I get a file that in protect password area? In reply to
Hi,

I have problem:
if I use this code :
Code:
$req = new HTTP::Request GET => 'http://www.server.com/secret/';
$req->authorization_basic('username', 'password');
It return the index page.
But I really whant to get a file in that directory for example data.txt. And I use the following code :
Code:
$req = new HTTP::Request GET => 'http://www.server.com/secret/data.txt';
$req->authorization_basic('username', 'password');
It returns a forbidden code.
Please advice.

Beck

Last edited by:

Beck: Oct 8, 2001, 7:15 PM
Quote Reply
Re: [Beck] How can I get a file that in protect password area? In reply to
Im guessing you changed www.server.com/secret/ to your servers' url?
Quote Reply
Re: [RedRum] How can I get a file that in protect password area? In reply to
Hi Paul,

Yes, I changed. But I really want to get a data file not the index file of the directory.

Thanks as always,

Beck
Quote Reply
Re: [Beck] How can I get a file that in protect password area? In reply to
Not sure. Have you read the documentation? It sounds to me like you need to Authenticate yourself to the server, then go in and retrieve the document. You can't do this in one go, it seems.

- wil