subprocess executing shell

Gabriel Genellina gagsl-py2 at
Thu Oct 22 11:07:07 CEST 2009

En Wed, 21 Oct 2009 12:24:37 -0300, Tim Arnold <tim.arnold at>  

> Hi, I'm writing a script to capture a command on the commandline and run  
> it
> on a remote server.
> I guess I don't understand subprocess because the code below exec's the
> user's .cshrc file even though by default shell=False in the Popen call.

Do you mean it execs the .cshrc file in your *local* system or the  
*remote* one?
Popen controls what happens on the local system only.

>         action.insert(0,'rsh my_remotehost')
>         p = subprocess.Popen(shlex.split(' '.join(action)))
>         p.wait()
> Since the shell is executing in the child process anyway, is the only
> difference when using shell=True is that environment variables can be
> expanded in the command to be executed?

Note that in this case, "the child process" is rsh on the local system.  
Popen has no control over what happens once rsh starts.

Gabriel Genellina

More information about the Python-list mailing list