(I'm assuming Linux and the bash shell here, since you didn't specify.) The problem is when you run './setup_vars' it runs in the context of another process and environment changes don't go 'backwards'. What you need to do is 'source' the file that contains the environment variables using the command '. ./setup_vars' and make sure setup_vars has an export command for each variable.
The 'su -' command suggested by Sumitro works because the '-' portion causes the ~/.bash_profile to be sourced when the process is created. Playing with %ENV will work, but it creates duplication of effort (i.e. its easier to keep environment assignments in one place, like .bash_profile). Finally, cron does not read your .bash_profile when it creates the process (like 'su -'), it only reads your .bashrc (like a plain 'su'). If you want to play with this, drop some echo's into your .bash_profile and .bashrc to see what the system does (and does not) do for you. HTH, Dave On Apr 24, Bruce Shaw scribed: > I've got a working dbi script but I can only get it going live. > > If I run it as a crontab entry, it won't work because there's no environment > variables. > > I've even tried something like: > > 12 23 * * * cd /usr/local/bin/mine; ./setup_vars; set > set.txt; > ./myscript.pl & > diag.txt > > where setup_vars is a script that's supposed to set my variables. I've also > got them set in .profile, but when I examine set.txt, none of the > environment variables are there and diag.txt shows that nothing has worked > because the variables are missing. > > What am I doing wrong? > > --- > Outgoing mail is certified Virus Free. > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.659 / Virus Database: 423 - Release Date: 4/15/2004 > > > This communication is intended for the use of the recipient to which it is > addressed, and may contain confidential, personal and or privileged > information. Please contact us immediately if you are not the intended > recipient of this communication, and do not copy, distribute, or take action > relying on it. Any communication received in error, or subsequent reply, > should be deleted or destroyed. >
