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, about StringIO... > 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 "/usr/local/lib/python2.4/subprocess.py", line 413, in call > return Popen(*args, **kwargs).wait() > File "/usr/local/lib/python2.4/subprocess.py", line 534, in __init__ > (p2cread, p2cwrite, > File "/usr/local/lib/python2.4/subprocess.py", line 840, in _get_handles > c2pwrite = stdout.fileno() > AttributeError: StringIO instance has no attribute 'fileno' > > So how do I get the output into a string? > > I thought that the idea of StringIO was that it could be > used where a file was expected. > > Thanks, > > Toby > ** Posted from http://www.teranews.com ** ** Posted from http://www.teranews.com ** -- http://mail.python.org/mailman/listinfo/python-list