emulating `` shell operator in Python?
Richard Gruet
rgruet at ina.fr
Fri Dec 3 09:44:24 EST 1999
Thank U, it works. In fact, I've already tried popen() one year ago, but
it behaved strangely on Windows (or I misused it). Now, everything looks
OK.
Adrian Eyre wrote:
> > - But the really tricky case is to catch in a string the output of a
> > *shell* command, such as os.system('ls').
> > The above strategy doesnt work because the command executes in a
> > sub-shell (external to python) with its own stdout and stderr.
>
> import os
>
> f = os.popen("ls", "r")
> s = f.read()
> f.close()
> print s
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/19991203/e5cfc6f5/attachment.html>
More information about the Python-list
mailing list