Hello!

On Fri, 9 Jan 2009, Koester, Chris wrote:

Scripts ran from cron give this error.

failed: ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env var  or PATH 
(Windows) and or NLS settings, permissions, etc. at 
/app/XOstats/prod/bin/util/check_user.pl line 43
Can't call method "disconnect" on an undefined value at 
/app/XOstats/prod/bin/util/check_user.pl line 69.

Web log give this error.

[Fri Jan 09 12:08:57 2009] [error] [client 172.31.48.85] Premature end of 
script headers: Login.pl
[Fri Jan 09 12:21:39 2009] [error] [client 172.31.48.85] install_driver(Oracle) 
failed: Can't load 
'/xst/xstlocal/bin/lib/perl5/site_perl/5.10.0/i86pc-solaris-thread-multi/auto/DBD/Oracle/Oracle.so'
 for module DBD::Oracle: ld.so.1: perl: fatal: libnnz10.so: open failed: No 
such file or directory at 
/xst/xstlocal/bin/lib/perl5/5.10.0/i86pc-solaris-thread-multi/DynaLoader.pm 
line 203.

For some reason its not recognizing the $ENV{…. } set with in the perl
scripts to identify ORACLE_HOME and other variables.
        Most ld.so implementations read environment only once. When your
application is loaded, ld.so is initialized first, therefore you usually
cannot change it's environment from your code.

$ENV{"ORACLE_HOME"}="/xst/xstlocal/bin/oracleInstantClient/instantclient_10_2";
$ENV{"TNS_ADMIN"}="/xst/xstlocal/bin/oracleInstantClient/instantclient_10_2";
$ENV{"LD_LIBRARY_PATH"}="/xst/xstlocal/bin/oracleInstantClient/instantclient_10_2:....

If I have the script from the command line with all the env variables
set correctly the script runs.   It basically does not recognize the
variables in the scripts.
        The best way to solve the problem is to set environment before
http server starts. (for example in its startup script).
        If you do not have access to httpd startup, and your script is
pure CGI (not FastCGI, not mod_perl, etc...), you can put something like
this to your script:
-------------------------------
#!/usr/bin/perl

BEGIN {
        if (not $ENV{"MYLIBSET"} and (not $ENV{"LD_LIBRARY_PATH"} or 
$ENV{"LD_LIBRARY_PATH"} !~ m#/xst/xstlocal/bin/oracleInstantClient/instantclient_10_2#)) {
                
$ENV{"LD_LIBRARY_PATH"}="/xst/xstlocal/bin/oracleInstantClient/instantclient_10_2:....";
                $ENV{"MYLIBSET"} = 1; # Just in case someone mangles 
LD_LIBRARY_PATH in/after exec()
                exec($0,@ARGV);
        }
}
-------------------------------

        It's ugly, but works.

                        Bye. Alex.

Reply via email to