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

The following script gets a web page when I run it from the command line. However, when accessing it via a web browser the $content is empty. I am on an i686 Linux and had errors with make test when installing LWP.

Side note: php also will not get html docs. Maybe it is related. Maybe it is a problem with Apache, but I looked over the conf files carefully.

use LWP::Simple;
print "Content-type: text/plain\n\n";
print "Test for LWP::Simple::get\n;
$content=get('http://adcn.com/index.html');
print "Content->$content";

Thanks

Replies are listed 'Best First'.
Re: LWP::Simple::get
by cfreak (Chaplain) on Oct 23, 2001 at 00:28 UTC
    I just tested this on my linux box here and it worked just fine. Run the script from the web browser and then check your error log. This should give an indication of the problem. Two possible problems:
    • The script's permissions are not set where apache can execute it.
    • The directory you are trying to run the script from doesn't have permission to exec cgi scripts
    Hope that helps
Re: LWP::Simple::get
by sm3g (Hermit) on Oct 23, 2001 at 02:18 UTC
    This might be just a typo here and not in the real script, but you missed the trailing " on the second print line. It should read:
    print "Test for LWP::Simple::get\n";
    I got big hairy errors with perl -w without that.
    Hope this helps.
Re: LWP::Simple::get
by mr_dont (Beadle) on Oct 23, 2001 at 00:53 UTC

    If it outputted properly from the command line, there is little chance that the error is due to a LWP module installation error.

    Also, why would you not just print:

    use LWP::Simple; print "Content-type: text/plain\n\n"; print "Test for LWP::Simple::get\n; $content=get('http://adcn.com/index.html'); print "$content";
    ???