This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author addict2tux
Recipients addict2tux
Date 2014-02-20.22:55:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1392936909.36.0.153013593454.issue20708@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2014-02-20 22:55:09addict2tuxsetrecipients: + addict2tux
2014-02-20 22:55:09addict2tuxsetmessageid: <1392936909.36.0.153013593454.issue20708@psf.upfronthosting.co.za>
2014-02-20 22:55:09addict2tuxlinkissue20708 messages
2014-02-20 22:55:08addict2tuxcreate