On Mar 13, 7:54 pm, [EMAIL PROTECTED] wrote: > On Mar 13, 5:57 am, "Gerard Flanagan" <[EMAIL PROTECTED]> wrote: > > > Hello, > > > I have a third party shell script which updates multiple environment > > values, and I want to investigate (and ultimately capture to python) > > the environment state after the script has run. > > First close the input so that the (sub) process > knows to terminate and flush the output. Then, > you can read from the output: > > import subprocess > import popen2 > > p = subprocess.Popen(["/bin/sh"], stdin=subprocess.PIPE, > stdout=subprocess.PIPE) > > p.stdin.write("env -i FOO=BAR\n") > p.stdin.close() > status = p.wait() > ret = p.stdout.readlines() > p.stdout.close() > > > print ret >
Perfect! Works a charm. Thanks for helping me out. Gerard -- http://mail.python.org/mailman/listinfo/python-list