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

Kent Johnson kent37 at tds.net
Thu Oct 4 21:57:03 CEST 2007


Andre Walker-Loud wrote:
> 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?

Use subprocess.Popen() with the cwd argument.

Kent


More information about the Tutor mailing list