help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-bash] Cron jobs and env vars


From: Mun
Subject: [Help-bash] Cron jobs and env vars
Date: Thu, 29 Nov 2012 20:05:13 -0800
User-agent: Mutt/1.5.21 (2010-09-15)

Hi,

I need to run a cron job that launches a script to set up environment
variables which are needed for a successive script call.  I have
included a representation of my script below.  I am experiencing
behavior which I cannot explain 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 the following:

   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

export SHELL="/bin/bash -i"

/path/setUpEnvVars arg1 arg2 &> /home/mun/out.log <<EOF_REGR

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 ---------------------------------


BASH_VERSION='3.2.25(1)-release'
And here is how my shell options are set by default:

------------------------------ Delimiter BEGIN --------------------------------

allexport       on
braceexpand     on
emacs           off
errexit         off
errtrace        off
functrace       off
hashall         on
histexpand      on
history         on
ignoreeof       on
interactive-comments    on
keyword         off
monitor         on
noclobber       on
noexec          off
noglob          off
nolog           off
notify          off
nounset         off
onecmd          off
physical        off
pipefail        off
posix           off
privileged      off
verbose         off
vi              on
xtrace          off

------------------------------- Delimiter END ---------------------------------


Thanks in advance for your assistance.

Regards,

-- 
Mun



reply via email to

[Prev in Thread] Current Thread [Next in Thread]