Re: Getting subprocess.call() output into a string?

2008-04-18 Thread Nick Stinemates
On Tue, Apr 15, 2008 at 11:16:01PM +0200, David wrote: Still, about StringIO... The module description says you can use it to read and write strings as files, not that you can use strings *everywhere* you can use files. In your specific case, StringIO doesn't work, because the stdout

Getting subprocess.call() output into a string?

2008-04-15 Thread Tobiah
I am not sure how to capture the output of a command using subprocess without creating a temp file. I was trying this: import StringIO import subprocess file = StringIO.StringIO() subprocess.call(ls, stdout = file) Traceback (most recent call last): File stdin, line 6, in ? File

Re: Getting subprocess.call() output into a string?

2008-04-15 Thread David
On Tue, Apr 15, 2008 at 10:36 PM, Tobiah [EMAIL PROTECTED] wrote: I am not sure how to capture the output of a command using subprocess without creating a temp file. I was trying this: import StringIO import subprocess file = StringIO.StringIO() subprocess.call(ls, stdout = file)

Re: Getting subprocess.call() output into a string?

2008-04-15 Thread Tobiah
On Tue, 15 Apr 2008 13:36:11 -0700, Tobiah wrote: I am not sure how to capture the output of a command using subprocess without creating a temp file. I was Sorry, I jumped into a secondary level of the docs, and didn't see it all. I guess I can use communicate() to get the output. Still,

Re: Getting subprocess.call() output into a string?

2008-04-15 Thread David
Still, about StringIO... The module description says you can use it to read and write strings as files, not that you can use strings *everywhere* you can use files. In your specific case, StringIO doesn't work, because the stdout redirection takes place at the operating system level (which