LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   correct @INC path not detected by web browser (https://www.linuxquestions.org/questions/linux-software-2/correct-%40inc-path-not-detected-by-web-browser-429666/)

mfitzpat 03-29-2006 10:40 AM

correct @INC path not detected by web browser
 
Hi,

I install RSPerl one of my systems. When I try to run a cgi script, the perl module R.pm can not found. I can run the script manually without any problem. I have manually set the LD_LIBRARY_PATH and PERL5LIB to the correct paths.

System info: running FC3, with apache 2.0.53, and perl 5.8.5.

RSPerl is installed
/usr/lib/R/library/RSPerl.
R.pm is located at
/usr/lib/R/library/RSPerl/share/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi/R.pm

When I try to run the script from /var/www/cgi-bin/mfitzpat via the web browser, the listed paths for finding R.pm in @INC are incorrect.

web browser error:
Can't locate R.pm in @INC (@INC contains: /usr/lib/perl5/5.8.5/i386-linux-thread-multi /usr/lib/perl5/5.8.5.....
EGIN failed--compilation aborted at /var/www/cgi-bin/mfitzpat/example3.pl line 4.

When I check @INC, the path to R.pm it is listed.

/$ perl -e 'print join "\n", @INC'
/usr/lib/R/library/RSPerl/share/lib/perl5/site_perl/5.8.5/i386-linux-thread-multi
as well as /usr/lib/perl5/5.8.5, etc


script fails at line 4
example3.cgi

#!/usr/bin/perl
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);
use R;

I have tried to append the full path to "use R", but it did not work. Gives a different error.

The httpd.conf relative entries
LoadModule cgi_module modules/mod_cgi.so

ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"

<Directory "/var/www/cgi-bin">
AllowOverride None
# Options None
Options ExecCGI
Order allow,deny
Allow from all
</Directory>

AddHandler cgi-script .c

So, my question is how can I get the correct @INC path for R.pm to be seen by the web browser?

Thank you for any advice.

theNbomr 03-30-2006 07:25 PM

Assuming your server is apache, you can modify httpd.conf...



Code:

#
# Environment variable setup
#
<IfModule mod_env.c>
    # Location of the application-specific perl modules.
    SetEnv YOUR_ENV_VAR /path/to/your/modules
</IfModule>


Then, in your perl code,

Code:

use lib $ENV{YOUR_ENV_VAR};
use yourModule;

There may be a more sanitary solution, but this works for me. I'd be happy to hear of a better method.

I guess you could just do:

Code:

use lib /path/to/your/modules;
....

Sure, why not.

--- rod.


All times are GMT -5. The time now is 05:43 PM.