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

Tiago Saboga tiagosaboga at terra.com.br
Thu Oct 4 22:10:08 CEST 2007

On Thu, Oct 04, 2007 at 03:15:41PM -0400, Andre Walker-Loud wrote:
> 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')

Have a look at the subprocess module. You should be able to do
something like:

subprocess.Popen(['path/my.executable'], cwd='path')

I am not sure of the actual keyword to be used, so please look at the


More information about the Tutor mailing list