Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Missing Modules

by jjeff007 (Initiate)
on Jul 18, 2016 at 15:28 UTC ( #1167981=perlquestion: print w/replies, xml ) Need Help??

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

I successfully installed all the modules my program requires on a new server but for some reason my CGI scripts are not finding two of them. I've reinstalled them multiple times.

Installing /usr/local/lib64/perl5/auto/JSON/XS/ Installing /usr/local/lib64/perl5/JSON/ Installing /usr/local/lib64/perl5/JSON/XS/ Installing /usr/local/share/man/man1/json_xs.1 Installing /usr/local/share/man/man3/JSON::XS.3pm Installing /usr/local/share/man/man3/JSON::XS::Boolean.3pm Installing /usr/local/bin/json_xs Appending installation info to /usr/lib64/perl5/perllocal.pod MLEHMANN/JSON-XS-3.02.tar.gz /usr/bin/make install -- OK

HTTPD Error Log

Can't locate JSON/ in @INC (@INC contains: /usr/local/lib64/perl +5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl +5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /var/www/cgi-bi +n/iprs/cips.cgi line 10., referer: +cips.html?switch=GB [Mon Jul 18 11:23:53 2016] [error] [client XXXXX] BEGIN failed--compil +ation aborted at /var/www/cgi-bin/iprs/cips.cgi line 10., referer: ht +tp://XXXX/daily_reports/cips.html?switch=GB [Mon Jul 18 11:23:53 2016] [error] [client XXXXX] Premature end of scr +ipt headers: cips.cgi, referer: http://XXXXX/daily_reports/cips.html? +switch=GB
[root@XXXX perl5]# perl -e "use JSON::XS;" [root@XXXX perl5]# which perl /usr/bin/perl [root@XXXXX iprs]# head cips.cgi #!/usr/bin/perl -w use LWP::UserAgent; use Data::Dumper; use JSON::XS;

This is also happening for my module Email::Stuff. Any thoughts? Is this a httpd issue?

Replies are listed 'Best First'.
Re: Missing Modules
by kcott (Bishop) on Jul 19, 2016 at 05:45 UTC

    G'day jjeff007,

    Welcome to the Monastery.

    The prompt you show in your tests (i.e. [root@XXXX perl5]#) suggests that you're running these tests as root. It's unlikely that your CGI scripts are being run by root. Determine which user is running your CGI scripts and then rerun your tests as this user: this may highlight the problem.

    Your "head cips.cgi" output has presumably been modified (there's no use CGI or other CGI code); however, you don't show what you've changed: a simple truncation or a more substantial modification (possibly including a reordering of the lines shown). The following is guesswork, as I'm pretty much working in the dark here, but consider:

    • Data::Dumper is a core module so I wouldn't expect problems with this regardless of user or perl version.
    • LWP::UserAgent is an installed module but you show no problems with this: cips.cgi appears to be reading LWP/ without any issues.
    • JSON::XS is also an installed module and cips.cgi does have problems reading JSON/ How do file permissions or Apache (or equivalent) configuration differ between LWP/ and JSON/
    • Use the strict pragma.
    • Use the warnings pragma instead of the -w switch as recommended in perlrun:
      "... the lexically scoped use warnings pragma is preferred."

    If the information I've provided results in a fix for JSON::XS, you may find this also leads to a solution for your Email::Stuff problem.

    — Ken

Re: Missing Modules
by neilwatson (Priest) on Jul 18, 2016 at 15:31 UTC

    Is the cgi program using the same perl as your shell test?

    Neil Watson

      I specify the interpreter in the cgi script It should be all the same

      [root@XXXX perl5]# which perl /usr/bin/perl [root@XXXX perl5]# head /var/www/cgi-bin/iprs/cips.cgi #!/usr/bin/perl -w use LWP::UserAgent; use Data::Dumper; use JSON::XS;
Re: Missing Modules
by haukex (Bishop) on Jul 19, 2016 at 11:37 UTC

    Hi jjeff007,

    Try running this from the browser and from the command line, maybe it will give you a clue:

    #!/usr/bin/env perl use warnings; use strict; use Config; use CGI qw/header/; print header('text/plain'); print "Perl $] at $^X, perlpath is $Config{perlpath}\n", "EUID/EGID: $>/$)\n", "\@INC:\n"; print +((-r)?'':'NOT READABLE: ')."\"$_\"\n" for @INC;

    Just remember to delete it from your webserver after you test; it may reveal information to an attacker.

    Hope this helps,
    -- Hauke D

Re: Missing Modules
by shmem (Chancellor) on Jul 18, 2016 at 21:33 UTC

    Strange. I'd start the web server in debug mode, i.e. single instance, and strace -o /tmp/debug.strace -s 4096 -f -p $PID that and grep the output for JSON/XS. That might give a clue.

    perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'
Re: Missing Modules
by Anonymous Monk on Jul 18, 2016 at 23:08 UTC
    check the permissions

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1167981]
Approved by marto
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2021-10-20 20:03 GMT
Find Nodes?
    Voting Booth?
    My first memorable Perl project was:

    Results (82 votes). Check out past polls.