subprocess & shared environments

Piet van Oostrum piet at cs.uu.nl
Fri May 1 09:45:29 CEST 2009


>>>>> Robert Dailey <rcdailey at gmail.com> (RD) wrote:

>RD> I'm currently calling subprocess.call() on a batch file (in Windows)
>RD> that sets a few environment variables that are needed by further
>RD> processes started via subprocess.call(). How can I persist the
>RD> environment modifications by the first call() function? I've done my
>RD> own searching on this and I came up with nothing.

Environments are propagated down the subprocess chain, not up. (I don't
know Windows good enough but I think this is also true on Windows.) What
you could do is have the batch file print the environment, read it in
your script and passing that environment to the other subprocesses. But
then why would you do it in a batch file? You could as well copy the
setting of the environment variables in your Python script. Or if the
batch file is supplied by another source, parse it and extract the
environment variables from it.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list