http://www.perlmonks.org?node_id=614194

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I know this is probably something that probably has been asked quite a few times....I have scanned through a lot of documentation ...a lot of queries posted on various groups etc..But still not able to get through this issue with the proxy on my network. Also the requests are Websensed. Here is a sample script I picked up from the code snippets on perl monks .... but this doesnt work...
#!/usr/bin/perl -w # dget.pl # pod at tail use strict; use LWP::UserAgent; use Getopt::Long; use Pod::Usage; use URI::URL; use LWP::Debug qw(+); my ($opt_help, $opt_man); GetOptions( 'help!' => \$opt_help, 'man!' => \$opt_man, ) or pod2usage(-verbose => 1) && exit; pod2usage(-verbose => 1) && exit if (defined $opt_help); pod2usage(-verbose => 2) && exit if (defined $opt_man); # Begin config parameters my %parm = ( url => shift, outfile => shift, uatimeout => 120, # seconds before giving up on fetch browser => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.9) Geck +o/20020310 ', ); my %proxy = ( host => 'http://proxy.mycomp.com:8080', # http://host.dom:port id => 'mynw\mylogin', # ntdom\userid pass => 'mypasswd', # empty quotes if no proxy auth ); # End config parameters unless(defined $parm{url}) { print "\n Ooot - you forgot to provide a URL !\n"; Ooot(); } unless(defined $parm{outfile}) { print "\n Ooot - your forgot to provide an outfile !\n"; Ooot(); } print "\n Fetching $parm{url}...\n"; my $ua = new LWP::UserAgent; $ua->agent($parm{browser}); $ua->timeout($parm{uatimeout}); $ua->proxy(http => "$proxy{host}") if (defined $proxy{host}); $parm{url} = new URI::URL($parm{url}); my $req = new HTTP::Request "GET" => ($parm{url}); $req->proxy_authorization_basic ($proxy{id}, $proxy{pass}) if (defined $proxy{id}); my $res = $ua->request($req); if ($res -> is_success) { my $rescont = $res->content; open (OUT, ">$parm{outfile}") or die "Error opening $parm{outfile} for write: $!"; print OUT $rescont; close OUT or die "Error closing $parm{outfile}: $!"; } else { my $resmsg = $res->message; print "Error fetching $parm{url}:\n $resmsg\n\n"; exit; } print " Done! Page saved at '$parm{outfile}'\n\n"; sub Ooot { print "\n dget.pl --help", "\n dget.pl --man", "\n", "\n LWP $LWP::VERSION", "\n Perl $]", "\n OS $^O", "\n Program $0", "\n\n", ; exit; } Outputs the following : D:\testperl>perl dget.pl http://google.com out.txt Fetching http://google.com... LWP::UserAgent::new: () LWP::UserAgent::proxy: http http://proxy.mycomp.com:8080 LWP::UserAgent::request: () LWP::UserAgent::send_request: GET http://google.com/ LWP::UserAgent::_need_proxy: Proxied to http://proxy.mycomp.com:8080 LWP::Protocol::http::request: () LWP::Protocol::collect: read 623 bytes LWP::Protocol::collect: read 1754 bytes LWP::UserAgent::request: Simple response: Proxy Authentication Require +d Error fetching http://google.com/: Proxy Authentication Required ( The ISA Server requires authorizatio +n to fulfi ll the request. Access to the Web Proxy service is denied. )
Please guide me to the right issue behind this.