Click here to get back home

download file from windows webserver box using LWP

 HomeNewsGroups | Search | About
 comp.lang.perl.modules    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
download file from windows webserver box using LWP becks007 11-03-2005
Get Chitika Premium
Posted by becks007 on November 3, 2005, 4:31 am
Please log in for more thread options


I have a windows box and linux box.

http://blabla.com is a windows box with IIS the site is built using
ASP.

Now i want to download a file from the windows box using HTTP(perl-LWP)
from the linux box, the site requires NTLM authentication. I have
written a code snippet(below)

----------------------------------------
#!/usr/bin/perl -w

use strict;
use warnings;
use LWP::UserAgent;
use LWP::Authen::Ntlm;
use HTTP::Request::Common;
use LWP::Debug qw(+);

$url = "http://blabla.com/docs/pdf/1.pdf"
$download = new LWP::UserAgent(keep_alive=>1);
$download->agent("Mozilla/3.0 (WinNT; I)");
$download->credentials('blabla.com:80'," ","username" => 'password');

my $request = HTTP::Request->new(GET => $url);

$response = $download->request($request);

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 output is as follows:
----------------------------------------
LWP::UserAgent::new: ()
LWP::UserAgent::request: ()
LWP::UserAgent::send_request: GET http://blabla.com/1.pdf
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 811 bytes
LWP::Protocol::collect: read 424 bytes
LWP::Protocol::collect: read 1472 bytes
LWP::Protocol::collect: read 1724 bytes
LWP::UserAgent::request: Simple response: Unauthorized
LWP::Authen::Ntlm::authenticate: authenticate() has been called
Use of uninitialized value in exists at
/usr/lib/perl5/vendor_perl/5.8.5/LWP/UserAgent.pm line 559.
LWP::Authen::Ntlm::authenticate: No username and password available
from get_basic_credentials(). Returning unmodified response object
Error: Negotiate, NTLM
401 Access Denied
at http://blabla.com/1.pdf
Aborting at ./temp.pl line 19.
----------------------------------------

Thanks in Advance
Anoob



Similar ThreadsPosted
System call fails in webserver February 11, 2006, 11:04 am
lwp-download http://..--how do I use it to download pages? June 8, 2008, 5:47 pm
GD demo cgi script works on command line but not on webserver. June 14, 2006, 5:07 am
Recursive download from the web February 4, 2005, 1:12 am
download all CPAN modules ? August 25, 2004, 10:35 pm
where can download Filter::netcrypt February 22, 2005, 9:55 pm
How to download web sites with www::robot April 11, 2005, 2:31 am
RFC: Catalyst::View::Download March 5, 2008, 1:36 pm
Perl Database Programing download for the template January 9, 2008, 12:56 pm
download Modules from CPAN and then load into Perl Question October 15, 2004, 3:07 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap