[SunHELP] FW: Environment variables not seen in cron'd perl scripts - CLARI FICATION

sunhelp at sunhelp.org sunhelp at sunhelp.org
Tue Jun 5 10:49:29 CDT 2001


First, I need to clarify some things (sorry)....   

The issue appears to be when calling DBI and DBD:Oracle from the perl
scripts (when running them in cron).  The LD_LIBRARY_PATH variable we're
trying to use points to the Oracle libraries, not the perl libraries. 

We are able to set the variables in the perl script using the Env module
(the script itself recognizes the variable), but it doesn't seem to get 
passed back up to the shell:

   use Env qw(LD_LIBRARY_PATH ORACLE_HOME);
   $LD_LIBRARY_PATH='/d01/app/oracle/product/8.1.7/lib';
   $ORACLE_HOME='/d01/app/oracle/product/8.1.7';  


We're trying to avoid writing "wrapper" shell scripts...

I'm also taking suggestions on the ideal perl mailing list to send this 
to if needed.

Thanks again in advance!

Andy Chandler
Systems Administrator
DICE.COM
515-313-2068 Phone
515-280-1452 FAX
AndyC at dice.com
http://www.dice.com



>  -----Original Message-----
> 
> Greetings Managers, et al.
> 
> I have some cron'd perl scripts that fail with library errors...  
> but they run fine by hand.  Basically, when running from cron, the 
> perl script can't seem to set the LD_LIBRARY_PATH variable (which is 
> in the script).  
> 
> I know that root's cron runs under a limited environment -- adding the 
> necessary environment variables to SHELL SCRIPTS works fine!  It's just 
> not working with perl scripts.
> 
> Any thoughts?
> 
> Thanks in advance.
> 




Next, thanks to those who responded quickly so far...

	
	Tim Conrad
	Christopher L. Barnard
	Matthew Lee Stier
	Justin Stringfellow

... who gave some nice suggestions based on my original description...

-----

(this one his hacky) copy libgdbm* from /usr/local/lib to /usr/lib

-----

move /usr/local/bin/perl to soomething like 'perl.pre'
write a wrapper script called perl that consists of:

  #!/bin/csh
  setenv LD_LIBRARY_PATH /usr/local/lib
  /usr/local/bin/perl.pre

-----

from cron, run shell scripts that set the necessary environment variables,
and
then run the perl scripts.

-----

Perl itself probably cannot find it's libraries.

Have you run 'ldd' against the 'perl' executable, and see what libraries it
needs at run time?

Try running "env LD_LIBRARY_PATH=<librarypath> perl ......" to run your Perl
program from within cron.

Another thing you may want to try, is to rebuild Perl, encoding the library
path into the executable. (ie: Set LD_RUN_PATH to the LD_LIBRARY_PATH you
want
the executable to have, before running 'make'.

-----

a) run the perl scripts from within a shell wrapper with the correct
environment 
set up in it

b) run them via "at" or "batch" since you _will_ get your current
environment 
this way










More information about the SunHELP mailing list