in reply to Cron and Expect.pm

This script will set up a shell with an environment pretty similar to what cron runs under. You should put it in a file (mine's called "barebash"), run it, and try your cron command from there.
#!/bin/sh logname=$USER home=$HOME for i in `env | sed 's/=.*//'`; do if [ X"$i" != XPATH ]; then unset $i fi done export LOGNAME=$logname export TERM=dumb export HOSTTYPE=i386 export PATH=/usr/bin:/bin export HOME=$home export SHELL=/bin/sh export OSTYPE=Linux export SHLVL=1 export _=/usr/bin/env exec bash -noprofile -norc $*

Replies are listed 'Best First'.
Re^2: Cron and Expect.pm
by tilly (Archbishop) on Nov 12, 2004 at 19:11 UTC
    Going the other way, you can use RE (tilly) 3: Get default login environment in your cron jobs to make their environments match what you normally see when you are logged in.

    Incidentally your script above is easy to write in Perl:

    #! /usr/bin/perl %ENV = ( LOGNAME => $ENV{LOGNAME}, TERM => "dumb", HOSTTYPE => "i386", PATH => "/usr/bin:/bin", HOME => $ENV{HOME}, SHELL => "/bin/sh", OSTYPE => "Linux", SHLVL => 1, _ => "/usr/bin/env", ); exec("bash", "-noprofile", "-norc", @ARGV);
    UPDATE: As pointed out by AM below, I was setting HOME twice. It makes more sense not to, so I've fixed that.
      Why is HOME set twice? Is it (so) important?
        theres no place like $HOME