popen3 Object

DelPiccolo Ivano ivano.delpiccolo at degroof.be
Wed Feb 13 05:14:15 EST 2002


Thanks It's more than enought
Thank yu very much.
"Graham Ashton" <graz at mindless.com> wrote in message
news:WIda8.5918$ZO2.295633 at stones...
> On Tue, 12 Feb 2002 13:07:30 +0000, DelPiccolo Ivano wrote:
>
> > How can I print the stdout of the popen3
> >
> > exemple :
> >
> > fileobjet = os.popen3("ls -la", "true" ) print ??????????
>
> Using Python 2.1 on Linux:
>
> ratchet% python
> Python 2.1 (#8, Aug 22 2001, 16:46:14)
> [GCC 2.95.2 20000220 (Debian GNU/Linux)] on linux2
> Type "copyright", "credits" or "license" for more information.
> >>> import os
> >>> os.popen3("echo foo", "t")
> (<open file '(fdopen)', mode 'w' at 0x8134478>, <open file '(fdopen)',
> mode 'r' at 0x8134168>, <open file '(fdopen)', mode 'r' at 0x8132e00>)
>
> So we know that popen3 returns three open file objects, the first one
> open for writing and the second two for reading. If you check the docs
> you'll see that they are the child's stdin, stdout and stderr. So,
> returning to the interactive python session:
>
> >>> stdIn, stdOut, stdErr = os.popen3("echo foo")
> >>> while 1:
> ...     line = stdOut.readline()
> ...     if line == "":
> ...         break
> ...     else:
> ...         print line,
> ...
> foo
> >>>
>
> Does that help any?
>
> --
> Graham





More information about the Python-list mailing list