[issue20708] commands has no "RANDOM" environment?
Yanming Xiao
report at bugs.python.org
Thu Feb 20 23:55:09 CET 2014
New submission from Yanming Xiao:
I saw this issue on Python 2.7.3 running on FreeBSD 9.1-64 and ubuntu 12.04-64. All under BASH.
It seems that the shell for the external script does not have the access to RANDOM environment variable. If I run the script directly,
the results are OK.
# python -V
Python 2.7.3
# ls *.sh
arquery.sh randomnumber.sh
# ./commands_bug.py
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION0.log
# ./randomnumber.sh
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION0.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION279970795912919.log
# ./randomnumber.sh
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION0.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION279970795912919.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION309000060807371.log
# ./randomnumber.sh
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION0.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION20000681632594.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION279970795912919.log
-rw-r--r-- 1 root netvcr 9 Feb 20 17:31 SESSION309000060807371.log
#
# randomnumber.sh
#set -x
#
randomnumber=$((RANDOM*10000000000+RANDOM*100000+RANDOM))
sid=SESSION${randomnumber}
echo "whatever" > ${sid}.log
ls -l SESSION*.log
#!/usr/local/bin/python
#
# bug_in_python.py
#
import os
import commands
def main():
cmdString = './randomnumber.sh'
outputString = commands.getstatusoutput(cmdString)
print outputString[1]
#
# program starts
#
if __name__ == '__main__':
main()
os._exit(0)
----------
components: Library (Lib)
files: commands_bug.py
messages: 211759
nosy: addict2tux
priority: normal
severity: normal
status: open
title: commands has no "RANDOM" environment?
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file34157/commands_bug.py
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue20708>
_______________________________________
More information about the Python-bugs-list
mailing list