GNU Info

Info Node: (python2.1-lib.info)popen2

(python2.1-lib.info)popen2


Next: time Prev: filecmp Up: Generic Operating System Services
Enter node , (file) or (file)node

Subprocesses with accessible I/O streams
========================================

Subprocesses with accessible standard I/O streams.

This manual section was written by Drew Csillag
<drew_csillag@geocities.com>.
This module allows you to spawn processes and connect to their
input/output/error pipes and obtain their return codes under UNIX and
Windows.

Note that starting with Python 2.0, this functionality is available
using functions from the `os' module which have the same names as the
factory functions here, but the order of the return values is more
intuitive in the `os' module variants.

The primary interface offered by this module is a trio of factory
functions.  For each of these, if BUFSIZE is specified, it specifies
the buffer size for the I/O pipes.  MODE, if provided, should be the
string `'b'' or `'t''; on Windows this is needed to determine whether
the file objects should be opened in binary or text mode.  The default
value for MODE is `'t''.

`popen2(cmd[, bufsize[, mode]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDOUT, CHILD_STDIN)'.

`popen3(cmd[, bufsize[, mode]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDOUT, CHILD_STDIN, CHILD_STDERR)'.

`popen4(cmd[, bufsize[, mode]])'
     Executes CMD as a sub-process.  Returns the file objects
     `(CHILD_STDOUT_AND_STDERR, CHILD_STDIN)'.  _Added in Python
     version 2.0_

On UNIX, a class defining the objects returned by the factory functions
is also available.  These are not used for the Windows implementation,
and are not available on that platform.

`Popen3(cmd[, capturestderr[, bufsize]])'
     This class represents a child process.  Normally, `Popen3'
     instances are created using the `popen2()' and `popen3()' factory
     functions described above.

     If not using one off the helper functions to create `Popen3'
     objects, the parameter CMD is the shell command to execute in a
     sub-process.  The CAPTURESTDERR flag, if true, specifies that the
     object should capture standard error output of the child process.
     The default is false.  If the BUFSIZE parameter is specified, it
     specifies the size of the I/O buffers to/from the child process.

`Popen4(cmd[, bufsize])'
     Similar to `Popen3', but always captures standard error into the
     same file object as standard output.  These are typically created
     using `popen4()'.  _Added in Python version 2.0_

Popen3 and Popen4 Objects

automatically generated by info2www version 1.2.2.9