From: gerry.butler on 23 Nov 2009 20:27 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.
From: Lie Ryan on 23 Nov 2009 20:40 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.
From: gerry.butler on 23 Nov 2009 21:11 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')
|
Pages: 1 Prev: python and netezza Next: (pywin related) pywintypes.com_error: -2147417846 "Application busy" |