Hi, I need to run a script via cron that in turn launches a script to set up the requisite environment variables needed for a successive script that is called. Moreover, I need to change my group ID in order for the scripts called within the cron job to run properly.
I have included a representation of my script below. It turns out that within my cron script, I am not seeing my group ID being changed (I call "id" for debug purposes). And even more puzzling is the behavior I'm seeing with the environment variables. I am using a here-document so that once the environment variables are set by "setUpEnvVars" (see below) they can be accessed by the successive calls (Note: Those calls are replaced by debug statements in the script below). When I echo or use the environment variables, they appear unset. Although, printenv correctly lists the environment variables with proper values. Environment variables that get set up via my profile (like $HOME) _are_ accessible within my here-document. In summary, I need help with two things: 1. How can I change my group ID within the cron script so that it applies to all successive calls--specifically within the here-document. 2. How can I access the environment variables set up by "setUpEnvVars" (see below) within the here-document? If I am approaching this problem incorrectly, please let me know. ------------------------------ Delimiter BEGIN -------------------------------- #! /bin/bash newgrp group1 id -g -n // This shows my login group ID, not group1 export SHELL="/bin/bash -i" /path/setUpEnvVars arg1 arg2 &> /home/mun/out.log <<EOF_REGR id -g -n // This shows my login group ID, not group1 printenv // Correctly dumps env vars set up via setUpEnvVars echo $VAR1 // VAR1 (set in setupEnvVars) appears unset printenv|grep VAR1 // VAR1 is correctly printed echo $HOME // HOME is correctly printed exit EOF_REGR ------------------------------- Delimiter END --------------------------------- Thanks in advance for your assistance. Regards, -- Mun