/srv/irclogs.ubuntu.com/2012/08/24/#upstart.txt

pixie79hi, can i create an env variable inside a pre-script whose variable is set by the output of a program, i.e env DATE=`date`10:43
pixie79as I have been trying but seem to get left with an empty variable10:43
ionIf you add “printf "%s\n" "$DATE" >/tmp/foo” after that, what will /tmp/foo contain?10:44
pixie79ion, i had been doing echo "TZ:$TZ" >> /tmp/tz which just gave me TZ:10:45
ionOh, also: you might want just ‘DATE="$(date)"’ or ‘export DATE="$(date)"’ in an sh script.10:45
ionCertainly not “env” in front of it.10:46
pixie79ok thanks that is correct, do i not need the 'env' in order to make is an environment variable which i can set for the main exec, ( i need to set the Timezone) the exec runs under10:49
pixie79hm, is this correct to check if a file exists and if it does not then exit printing a warning to daemon log. At the moment it seems to be stopping me when the file exists and printing nothing  [ ! -e $COMPFI ] && { echo "please enter CUST and COMP correctly" | logger -t CASS -p daemon.info ; stop; exit 0; }10:55
ionAlas, you can’t teleport environment variables between scripts just by setting them. You’ll need to set them in the main script and exec the final program in the end.10:59
pixie79ion ok, in that case i will move the tz to a main script, 11:00
ionYou might want to add something like this to the beginning of the script to debug it:11:00
ionexec >/tmp/jobname.out 2>&111:00
ionset -x11:00
pixie79thanks - i had not seen the exec/set -x before, looks useful, 11:03
pixie79ion: are these expecting bash style tests or something else ? as I am trying '!-e' to stop if the file does not exist11:07
ionif ! [ -e "$file" ]; then stop; exit; fi or something.11:08
pixie79ok that seems to be working better, now i just need to work out how to set the environment variable TZ so that when i exec the correct timezone is set, I have the value $TZ in the main script now correctly11:19
pixie79if i do: 'exec TZ=$TZ date' then i get an error that is tries to exec /TZ=Europe/London11:21
ionexport TZ11:23
ionexec date11:23
pixie79arh - thanks thought i had tried that one :)11:24
pixie79ion: thanks for your help - i now have a working script, 1 down 2 to fix :)11:28

Generated by irclog2html.py 2.7 by Marius Gedminas - find it at mg.pov.lt!