in reply to running .profile

A non-Perl solution would be to source the .profile in the crontab entry before running the script.

0 12 * * * . /home/dave/.profile;/path/to/script.pl

Update: Changed source to .. cron always uses the Bourne shell :(

--
<http://www.dave.org.uk>

"Perl makes the fun jobs fun
and the boring jobs bearable" - me

Replies are listed 'Best First'.
Re: Re: running .profile
by mouse (Novice) on May 02, 2001 at 16:33 UTC

    this doesn't seem to work. i have created a simple test script:

    #!/usr/local/bin/perl -w use strict; foreach (keys %ENV) { print "[$_] $ENV{$_}\n"; }

    next i created a .profile file with some oracle environment variables in it.

    when i insert the following line in cron:

    * * * * * source /opt/home/u_huiar1/.profile;/opt/home/u_huiar1/perl/c +ron.pl 1>> /opt/home/u_huiar1/perl/output 2>&1

    the file 'output' contains the following lines:

    [LOGNAME] u_huiar1 [PATH] /usr/bin: [SHELL] /usr/bin/sh [HOME] /home/u_huiar1 [TZ] MET

    somehow it does not have the oracle environment variables in its environment.

    arjan huijzer

      source is particular to the csh shell (maybe bash/zsh/etc). Perhaps you are using ksh or sh. Try:
      * * * * * . /opt/home/u_huiar1/.profile;/opt/home/u_huiar1/perl/c +ron.pl 1>> /opt/home/u_huiar1/perl/output 2>&1
      ksh and sh use "." (the dot command) to source files.
        Thanks! This is what i was looking for.

        Arjan