in reply to Re: Re: Can't locate LWP/UserAgent.pm
in thread Can't locate LWP/UserAgent.pm

K,

It looks as though @INC for you doesn't include a version of perl with LWP::UserAgent.pm installed, whereas @INC for the webserver (usually 'nobody') does use a version of perl with the module.

First off, run this cmd: locate perl | more That will show you all the places where perl is installed on the machine. My suspicion is that you have two versions of perl installed: 5.8.x is installed for users, and the web server is using some other version. If so, you'll see this kind of thing (minus my comments w arrows):

... /usr/lib/perl5/5.6.0 <--- version 5.6.0 of perl ... /usr/local/lib/perl5/5.6.1/CGI.pm <--- diff version --More--

Edit: I didn't notice that you said the webserver is using 5.005x. Teach me not to read carefully.

You (meaning your user account) seems to be using 5.8.x, which has no LWP::UserAgent.pm installed.

You haven't said why you've decided to test this CGI script by running it from the command line, but you might consider using CGI::Carp, which will send error messages to the browser. And since it will be running as the web server, it will execute using the 5.005x version of perl that has LWP.

Another solution is to remove the 5.8x version of perl from your $PATH variable, and add the 5.005x version. To do so, you'll have to find the 5.005x version--use 'locate perl | grep "5.005" | more; or something similar, and add the path to the 5.005 interpreter to your $PATH.

AH

Replies are listed 'Best First'.
Re: Re: Re: Re: Can't locate LWP/UserAgent.pm
by kryberg (Pilgrim) on Aug 06, 2003 at 14:03 UTC
    Thank you for all the suggestions. I'm not an administrator and the server is in a different state, so this is a little beyond my knowledge, but I'm talking to one of the people in charge of the server.

    I do have use CGI::Carp 'fatalsToBrowser'; in my script and no errors show up in the browser.

    I just like testing it from the command line because that's where I do the programming and it's quick and easy. Also, the system it is on is a replicated distributed file system (using AFS). It replicates to multiple web servers every 15 minutes, so it takes up to 15 minutes for the script to work in my browser when connecting to the web site. I can force it to replicate, but it would just be quicker to test it at the command prompt.

      Boy, that is strange. I don't know what would cause fatalsToBrowser not to work--unless of course perl can't find the CGI module.

      It looks like you'll have to stick with running it on the command line. Have you tried changing your path to point to 5.005x version of perl, instead of 5.8? That's probably a good first step.

      Another thing to try is run it using perl -c yourscript.pl. That will show you the compilation errors right at the command line. Once you get those cleared up (by installing missing modules, etc, you'll be in better shape to start testing that script.

      I'd still recommend running it from a browser though--there might be problems that come up when running it from the webserver that don't from the commandline, and vice versa. Also, you avoid spending your time on problems that are not an issue when it's run as a CGI script.

      AH

Re^4: Can't locate LWP/UserAgent.pm
by Anonymous Monk on Mar 26, 2013 at 21:15 UTC
    Make sure your perl /usr/bin/perl pointing to correct version cd /usr/bin perl -> ../perl5/5.8.4/bin/perl rm perl ln -s perl /usr/local/bin/perl5.12.0 started working