On Tue, Aug 24, 2010 at 12:18 PM, Astan Chee <astan.c...@al.com.au> wrote: > Hi, > I'm trying to convert my tcsh script to python and am stuck at one part, > particularly the part of the script that looks like this: > > #!/bin/tcsh > setenv LSFLOG /var/tmp/lsf_log > source /etc/setup > unalias cp > umask 0 > env >> ${AFLOG} > > What is the equivalent of doing this in python2.5?
I agree with Stefan, but anyway, here's an approximate untested literal translation: import os import subprocess os.environ['LSFLOG'] = '/var/tmp/lsf_log' subprocess.check_call(['tcsh', '/etc/setup']) os.umask(0) out = open(os.environ['AFLOG'], 'a') subprocess.check_call(['env'], stdout=out) out.close() Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list