Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
While not exactly a Perl question, I hope the members of the monastery will indulge me.

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:

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. before I change it:
$VAR1 = { 'HOME' => '/home/stella/reach', 'LOGNAME' => 'reach', 'SHELL' => '/usr/bin/sh', 'TZ' => 'US/Eastern', 'PATH' => '/usr/bin:' };
$ENV. after I change it:
$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' };
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.

Any thoughts or suggestions? As always, thank you for your time.

Cheers,

Brent

-- Yeah, I'm a Delt.

In reply to cron vs bash (solved) by dorko

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2024-04-23 13:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found