Stdout

hlubenow hlubenow2 at gmx.net
Sat Apr 14 14:16:36 EDT 2007


gbastian at pasteur.fr wrote:

> Dear Users,
> 
> I am trying to recover through the python function
> popen3 the stdout,in,err of a launched process.
> 
> I would like also to recover the stdout which you can
> get only through the command:   command1 >& filename
> 
> Do you know how I can access to that stdout by python?
> 
> Thanks
> 
> GIacomo

Check out module "subprocess" which is meant to replace function "popen3":

pr = subprocess.Popen(["command", "-option1", "-option2"], stdin =
subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.PIPE,
bufsize = 0, close_fds = True)

# And then:
line = pr.stdout.readline()
print line
pr.stdin.write("hello to command")

HTH

H.



More information about the Python-list mailing list