changing current dir and executing a shell script

Dan Stromberg drsalists at gmail.com
Fri May 27 18:14:35 EDT 2011


Each command will be run in a distinct subprocess.  A CWD is typically local
to a given subprocess.  So after the first command/subprocess exits, your
cd's change is no longer there.

Try doing it in one command, with the two original commands separated by a
semicolon.

On Fri, May 27, 2011 at 2:25 PM, suresh <suresh.amritapuri at gmail.com> wrote:

> Hi,
> I want to execute the following command line stuff from inside python.
> $cd directory
> $./executable
>
> I tried the following but I get errors
> import subprocess
> subprocess.check_call('cd dir_name;./executable')
>
> Due to filename path issues, I cannot try this version.
> subprocess.check_call('./dir_name/executable')
>
> Any suggestions?
> thanks
> suresh
> --
> http://mail.python.org/mailman/listinfo/python-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20110527/9694b907/attachment.html>


More information about the Python-list mailing list