Joining stdout & stderr of subprocess ?

Nick Craig-Wood nick at craig-wood.com
Fri Apr 21 10:30:06 EDT 2006


robert <no-spam at no-spam-no-spam.com> wrote:
>  when I run a command
> 
>  myapp 2>&1

Try

  myapp 2>&1 | cat

and see what you get.  You should get the same output as the python.

>  #!python
>  print os.popen("myapp 2>&1").read()
> 
>  the stderr stuff comes all after the stdout stuff.
>  How can I get ahold of all the out and err joined synchronously in the 
>  order, it is created ?

You need to either

1) change myapp to fflush() more often

2) investigate the python pty module to fool the app into thinking it
is talking to a terminal

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list