dorko has asked for the wisdom of the Perl Monks concerning the following question:
I've got a Perl script on a Solaris server that runs fine from an interactive command line. The script fails when run under cron. The use statements seem to succeed, because the script partially runs and does provide some correct output. The exact error message is 500 Can't locate object method "new" via package "LWP::Protocol::https::Socket" at /home/stella/reach/grades/modules/Vista/Sdk.pm line 333 I'm using LWP and HTTPS, but if Perl couldn't find the OpenSSL libraries, it would have given me a different kind of error, right?
My research leads me to believe this a problem with the environment variables not being the same in the shell vs cron. I've added code in a begin block to change the $ENV variable.
printenv results:
$ENV. before I change it:LC_MONETARY=en_US.ISO8859-1 TERM=vt100 SHELL=/bin/sh SSH_CLIENT=10.173.87.94 3688 22 LC_NUMERIC=en_US.ISO8859-1 SSH_TTY=/dev/pts/3 USER=reach LD_LIBRARY_PATH=/local/ssl/lib:/local/gnu/lib/:/local/lib/ PATH=/sbin:/local/gnu/bin:/usr/local/bin:/usr/sbin:/usr/bin:/etc:/usr/ +openwin/bin:/opt/SUNWspro/bin:/usr/ucb:/usr/ccs/bin:/usr/dt/bin:/usr/ +sfw/sbin:/usr/sfw/bin MAIL=/var/mail//reach LC_MESSAGES=C LC_COLLATE=en_US.ISO8859-1 PWD=/usr/local/lib/perl5/site_perl/5.10.1/Net EDITOR=pico TZ=US/Eastern PS1=\u@\h:\w$ SHLVL=1 HOME=/home/stella/reach LOGNAME=reach SSH_CONNECTION=10.173.87.94 3688 10.171.240.149 22 LC_CTYPE=en_US.ISO8859-1 LC_TIME=en_US.ISO8859-1 _=/usr/ucb/printenv OLDPWD=/usr/local/lib/perl5/site_perl/5.10.1/LWP/Protocol
$ENV. after I change it:$VAR1 = { 'HOME' => '/home/stella/reach', 'LOGNAME' => 'reach', 'SHELL' => '/usr/bin/sh', 'TZ' => 'US/Eastern', 'PATH' => '/usr/bin:' };
Now obviously I didn't bring all the environment variable over into cron, but I can't see how some of them would make a difference.$VAR1 = { 'HOME' => '/home/stella/reach', 'LOGNAME' => 'reach', 'SHELL' => '/usr/bin/sh', 'LD_LIBRARY_PATH' => '/local/ssl/lib:/local/gnu/lib/:/local/ +lib', 'TZ' => 'US/Eastern', 'PATH' => '/sbin:/local/gnu/bin:/usr/local/bin:/usr/sbin:/us +r/bin:/etc:/usr/openwin/bin:/opt/SUNWspro/bin:/usr/ucb:/usr/ccs/bin:/ +usr/dt/bin:/usr/sfw/sbin:/usr/sfw/bin' };
Any thoughts or suggestions? As always, thank you for your time.
Cheers,
Brent
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: cron vs bash
by bart (Canon) on Jun 04, 2010 at 14:26 UTC | |
Re: cron vs bash
by Anonymous Monk on Jun 04, 2010 at 14:39 UTC | |
by dorko (Prior) on Jun 04, 2010 at 19:19 UTC | |
Re: cron vs bash
by JavaFan (Canon) on Jun 04, 2010 at 15:40 UTC |