Re: Capturing output of os.system to a string

2009-11-23 Thread gerry.butler
Thank you. I'll look at subprocess. I have since found that commands will do it too, eg, (status, txt) = commands.getstatusoutput('whoami') or txt = commands.getoutput('whoami') -- http://mail.python.org/mailman/listinfo/python-list

Re: Capturing output of os.system to a string

2009-11-23 Thread Lie Ryan
gerry.butler wrote: How do I capture output to a string? For example, the output of os.system('whoami'). I guess I need to redirect stdout, but I'm a total beginner, and I haven't been able to find out from the tutorials how to do this. You can't with os.system; use subprocess module instead.

Re: Capturing output of os.system to a string

2009-11-23 Thread Stephen Hansen
On Mon, Nov 23, 2009 at 5:27 PM, gerry.butler wrote: > How do I capture output to a string? For example, the output of > os.system('whoami'). > > I guess I need to redirect stdout, but I'm a total beginner, and I > haven't been able to find out from the tutorials how to do this. > > You don't; os.

Capturing output of os.system to a string

2009-11-23 Thread gerry.butler
How do I capture output to a string? For example, the output of os.system('whoami'). I guess I need to redirect stdout, but I'm a total beginner, and I haven't been able to find out from the tutorials how to do this. -- http://mail.python.org/mailman/listinfo/python-list