By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,767 Members | 1,995 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,767 IT Pros & Developers. It's quick & easy.

subprocess with shared environment?

P: n/a
I'd like to replace some shell scripts with Python, but one step of
the script modifies my environment in a way that the subsequent steps
require.

A simple translation to a few lines of subprocess.call(...) fails
because the first call modifies the environment, but the other lines
don't see it.

Is there a straightforward way to do this (without having to resort
to writing some of it as a shell script)?

-- Russell
Nov 17 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
En Mon, 17 Nov 2008 21:27:09 -0200, rowen <ro***@u.washington.edu>
escribió:
I'd like to replace some shell scripts with Python, but one step of
the script modifies my environment in a way that the subsequent steps
require.

A simple translation to a few lines of subprocess.call(...) fails
because the first call modifies the environment, but the other lines
don't see it.

Is there a straightforward way to do this (without having to resort
to writing some of it as a shell script)?
The first subprocess modifies *its* environment and dies - the
modification is not seen by the caller process. I don't know of any way to
modify parent's environment.
You might "echo" the desired changes in the first subprocess, read them
from the parent process and modify the environment that will be passed to
later subprocesses. Perhaps someone else provides a more straightforward
solution...

--
Gabriel Genellina

Nov 18 '08 #2

P: n/a
On Nov 18, 9:27*am, rowen <ro...@u.washington.eduwrote:
I'd like to replace some shell scripts with Python, but one step of
the script modifies my environment in a way that the subsequent steps
require.
Is there a straightforward *way to do this (without having to resort
to writing some of it as a shell script)?
Perhaps using os.environ?

http://www.python.org/doc/2.5.2/lib/os-procinfo.html
Nov 18 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.