in reply to Perl/UNIX .profile problem

The root problem is that cron jobs run with a restricted environment.

The simplest solution is to edit interface's crontab, either setting SECTRAN_DIR = /home/interface/sectran at the top of the crontab file, or else in the command line which runs each script that needs it.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re^2: Perl/UNIX .profile problem
by marcelo.magallon (Acolyte) on Nov 18, 2004 at 16:46 UTC

    Actually it's not that cronjobs run in a restricted shell, the problem is that the OP is writing this settings to ~/.profile, which according to the docs:

    When Bash is invoked as an interactive login shell, or as a non-interactive shell with the `--login' option, it first reads and executes commands from the file `/etc/profile', if that file exists. After reading that file, it looks for `~/.bash_profile', `~/.bash_login', and `~/.profile', in that order, and reads and executes commands from the first one that exists and is readable.

    Pardon me for quoting the Bash docs, but this applies to any Bourne-type Shell.

    Translated to english: the shell that runs a cronjob is not an interactive shell, therefor your profile is not being read. There might be no shell at all (depending on the cron implementation). This is way your carefully crafted PATH sometimes doesn't work when calling things from a cronjob. You can either do what brother Zaxo says, or you can write a shell script and put all your settings there (PATH, SECTRAN_DIR, PERL5LIB, whatever).

Re^2: Perl/UNIX .profile problem
by elwarren (Priest) on Nov 18, 2004 at 18:06 UTC
    BTW, you can locally set an environment variable on the same command line when you run your script like this:

    SECTRAN_DIR=/home/interface/sectran script.pl