[Baypiggies] how can I change the input parameter in my executable while calling from either os.system or os.popen calls?
Matt Good
matt at matt-good.net
Thu Aug 21 22:39:11 CEST 2008
On Aug 21, 2008, at 10:01 AM, Joshua Gallagher wrote:
> There may be another, and better, way of doing it, but I usually use
> Popen like this:
> cmd = <something>
> p_obj = subprocess.Popen(cmd, shell=True,
> stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT)
> output = p_obj.stdout.read()
Using the std* streams directly is prone to deadlock. If you can,
stick to using popen.communicate()
proc = subprocess.Popen([cmd, arg1, arg2], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
pout, perr = subprocess.communicate()
http://docs.python.org/lib/node532.html
-- Matt
More information about the Baypiggies
mailing list