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

Alan Gauld alan.gauld at btinternet.com
Thu Oct 4 23:13:00 CEST 2007


"Andre Walker-Loud" <walksloud at gmail.com> wrote

> If I were using CSH, I could do all this very simply by having these
> lines in my script
>
> ### .csh file
>
> cd /scratch
> my_exe.csh

The best answer is to use subprocess as Kent suggested
but you can also use os.chdir(path) before using os.system()
But system() is deprecated in favour of the subprocess module.

Of course you could also modify your script to take a
path as a command line argument and use that to direct
the output explicitly...

Alan G.




More information about the Tutor mailing list