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":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.