Thanks for all the help. I think Chris's answer is the one I can use. I know its probably better to convert the /etc/setup file into python but it'll do for now. Also, the entire tsch script is just setting up env vars and such; various mvs and cps. Not really executing anything.
Thanks again for the help.

Chris Rebert wrote:
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

Reply via email to