tc1364 has asked for the wisdom of the Perl Monks concerning the following question:

Unable to run code as a cron job on a Unix box but when running the code from the command line it works fine. The Perl code creates a child process that calls a subroutine that executes a Expect script (non-Perl). Can you please show me how to set up my PATH correctly so that it will run as a cron job? Several things have been tried but with no success.

2006-03-03 Retitled by planetscape, as per Monastery guidelines
Original title: 'Path Trouble'

Replies are listed 'Best First'.
Re: (OT) Path Trouble
by philcrow (Priest) on Mar 02, 2006 at 17:34 UTC
    We use absolute paths in cron scripts. This is sort of for security and mostly to avoid environment issues like the one you seem to be hitting.

    Phil

      Yes and it is there. Please see below. # CSCANS Automation 45 12 * * 0-6 /ossd/tc1364/cscans/bin/start_cscans.pl
        I don't mean just in the cron entry. I also mean inside that script, whenever it refers to other scripts, the paths used are all absolute.

        Phil

Re: (OT) Path Trouble
by rinceWind (Monsignor) on Mar 02, 2006 at 17:17 UTC

    You may well find that PATH is not being set by cron as it is not sourcing in .bashrc or .profile - this is expected and normal behaviour.

    You have access to PATH as $ENV{PATH}, which you can set inside your script before you fork. %ENV is available for dumping out for debugging purposes.

    --

    Oh Lord, won’t you burn me a Knoppix CD ?
    My friends all rate Windows, I must disagree.
    Your powers of persuasion will set them all free,
    So oh Lord, won’t you burn me a Knoppix CD ?
    (Missquoting Janis Joplin)

      This was already tried and didn't work. The cron job returns the below. Also, the local to this object code is in my PATH. Your "cron" job on osdsun60 /ossd/tc1364/cscans/bin/start_cscans.pl produced the following output: ld.so.1: dms_start.exp: fatal: libtcl8.3.so: open failed: No such file or direct ory Killed commands will be executed using /usr/bin/sh job 1141324921.a at Thu Mar 2 12:42:01 2006

        Looks from the diagnostic that the problem might be with $ENV{LD_LIBRARY_PATH} rather than $ENV{PATH}. Which flavour of Unix are you running?

        By the way, for readability, could you please put <code> tags around your output.

        --

        Oh Lord, won’t you burn me a Knoppix CD ?
        My friends all rate Windows, I must disagree.
        Your powers of persuasion will set them all free,
        So oh Lord, won’t you burn me a Knoppix CD ?
        (Missquoting Janis Joplin)