how to change os.popen4 to subprocess
chenyong20000 at gmail.com
Sat Oct 27 08:30:52 CEST 2012
On Oct 27, 11:02 am, MRAB <pyt... at mrabarnett.plus.com> wrote:
> On 2012-10-27 03:28, skyworld wrote:> Hi,
> > I'm new to python and I'm trying to porting some scripts from v0.96 to
> > v2.0.1. A piece of code is like this:
> > cmd_h = os.popen4(env['SYSCMDLINE'])
> > the system indicates the popen4 is deprecated and suggest to use
> > subprocess. Can anybody tell me how to use subprocess in this case?
> > and what does "" here means?
> os.popen4 returns a tuple of (child_stdin, child_stdout_and_stderr).
> The  gets the child_stdout_and_stderr member.
> Using the subprocess module:
> # Untested!
> cmd_h = subprocess.Popen(env['SYSCMDLINE'], stdout=subprocess.PIPE,
> stderr=subprocess.STDOUT, shell=True).stdout
> The command line: env['SYSCMDLINE']
> Return stdout: stdout=subprocess.PIPE
> stderr should be combined with stdout: stderr=subprocess.STDOUT
> Let the shell parse the command line: shell=True
More information about the Python-list