[Tutor] using python to execute from Dir A in Dir B

Andre Walker-Loud walksloud at gmail.com
Thu Oct 4 21:15:41 CEST 2007

Hi All,

lets say I am in Dir A (out of my control because I have submitted a  
job to a queuing system)

and I have a python script which is running in this directory - the  
one I submitted to the queue

what I need to do is have my python script run another executable,  
but it must do it from a directory different from the one I am in, it  
needs to run in the /scratch/ directory (again not my choice)

Is this possible, and is it easy?

the way I have been using python to run other executables is

os.system('path/my.executable input')

but this dumps the output in the directory I am currently in, and not  
the directory the my.executable lives in - I am hoping there is a  
simple way to tell python to run the executable in its directory, and  
have its output live there as well.

If I were using CSH, I could do all this very simply by having these  
lines in my script

### .csh file

cd /scratch

I am hoping this idea makes sense and is simple with python...


More information about the Tutor mailing list