S
Stephen Cattaneo
Hello all,
I am attempting to execute an automated test (written in Python) via
cron. I have to check the HOSTNAME variable as part of the test, oddly
under cron the HOSTNAME environment variable is not in the os.environ
dictionary. I know that cron runs in a subshell that does not have all
of the normally set environment variables. HOSTNAME is not one of those
variables, it is set even in cron's subshell. Why doesn't python get
this variable? Is this a bug in python2.4?
convention)-
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING='set; echo "-----------------"; echo "import os;
print os.environ" | python'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="1" [4]="release"
[5]="i686-redhat-linux-gnu")
BASH_VERSION='3.1.17(1)-release'
DIRSTACK=()
EUID=501
GROUPS=()
HOME=/home/regression
HOSTNAME=regress5
HOSTTYPE=i686
IFS=$' \t\n'
LOGNAME=regression
MACHTYPE=i686-redhat-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/bin:/bin:/usr/bin:/home/regression/bin
PPID=819
PS4='+ '
PWD=/home/regression
PYTHONPATH=/home/regression/lib
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
TERM=xterm
UID=501
USER=regression
_=/bin/bash
-----------------
{'TERM': 'xterm', 'SHELL': '/bin/bash', 'SHLVL': '1', 'PYTHONPATH':
'/home/regression/lib', 'PWD': '/home/regression', 'LOGNAME':
'regression', 'USER': 'regression', 'HOME': '/home/regression', 'PATH':
'/usr/local/bin:/bin:/usr/bin:/home/regression/bin', '_':
'/usr/bin/python'}
Thanks,
Steve
I am attempting to execute an automated test (written in Python) via
cron. I have to check the HOSTNAME variable as part of the test, oddly
under cron the HOSTNAME environment variable is not in the os.environ
dictionary. I know that cron runs in a subshell that does not have all
of the normally set environment variables. HOSTNAME is not one of those
variables, it is set even in cron's subshell. Why doesn't python get
this variable? Is this a bug in python2.4?
python's os.environ (please excuse my lack of creativity in namingFrom a cronjob to check environment variables in cron's shell vs
convention)-
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_EXECUTION_STRING='set; echo "-----------------"; echo "import os;
print os.environ" | python'
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="1" [2]="17" [3]="1" [4]="release"
[5]="i686-redhat-linux-gnu")
BASH_VERSION='3.1.17(1)-release'
DIRSTACK=()
EUID=501
GROUPS=()
HOME=/home/regression
HOSTNAME=regress5
HOSTTYPE=i686
IFS=$' \t\n'
LOGNAME=regression
MACHTYPE=i686-redhat-linux-gnu
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/bin:/bin:/usr/bin:/home/regression/bin
PPID=819
PS4='+ '
PWD=/home/regression
PYTHONPATH=/home/regression/lib
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
TERM=xterm
UID=501
USER=regression
_=/bin/bash
-----------------
{'TERM': 'xterm', 'SHELL': '/bin/bash', 'SHLVL': '1', 'PYTHONPATH':
'/home/regression/lib', 'PWD': '/home/regression', 'LOGNAME':
'regression', 'USER': 'regression', 'HOME': '/home/regression', 'PATH':
'/usr/local/bin:/bin:/usr/bin:/home/regression/bin', '_':
'/usr/bin/python'}
Thanks,
Steve