in reply to Re^3: WGET equivalent
in thread WGET equivalent

ok, I seem to have addressed this, LWP::user agent's is_success returns "permission denied" I am not writing anything here, just using a module. Do I need to figure out how to change permission so I can use modules?

Replies are listed 'Best First'.
Re^5: WGET equivalent
by Corion (Patriarch) on Feb 02, 2008 at 14:39 UTC

    Sorry, but without any code or anything that you show us, it's near impossible to diagnose (or even fix) the error you're getting.

    Maybe the permission denied comes from a malformed URL you're requesting? Reduce your script to the minimum code that still fails, and post that.

      here is an example of my script with most of the details eliminated, still producing a  permission denied error. Most mysterious!
      #!/usr/local/bin/perl -w use strict; use CGI qw(:standard); use CGI::Carp qw(warningsToBrowser fatalsToBrowser carpout); use lib qw(/usr/lib/perl5/vendor_perl/5.8.6/LWP /usr/lib/perl5/vendor_ +perl/5.8.6 / /usr/lib/perl5/vendor_perl/5.8.6/LWP/UserAgent.pm); use LWP::UserAgent; my $ua = LWP::UserAgent->new; $ua->timeout(10); $ua->agent('Mozilla/5.0'); my $current_page = "http://www.perlmonks.org"; my $response = $ua->get($current_page); my $data = $response->content if($response->is_success) or die "not su +ccessful $!\n"; if($data){ print "page: $current_page\n$data\ndone", length($data); } else { print "no data\n"; }
        Your script works for me.

        BTW the use lib ... line looks like cargo cult programming - you don't know what it means, but write it nevertheless in the hope that it will help.

        With use lib @list you specify directories in which perl searches for modules. The last entry doesn't look a like a directory at all, so remove it. And it's somewhat unusual to have modules in /, so that probably isn't needed as well.

        Not mysterious. LWP::UserAgent does not set $!. The "permission denied" message you're seeing is just an artifact of $! having some value resulting from some system call.

        I recommend using $response->as_string() to inspect what you get back, and

        die $response->status_line;

        (as the documentation of HTTP::Response suggests).