Joining stdout & stderr of subprocess ?
Stephane Chazelas
stephane_chazelas at yahoo.fr
Fri Apr 21 13:04:04 EDT 2006
On Fri, 21 Apr 2006 09:30:06 -0500, Nick Craig-Wood wrote:
> 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
[...]
3) write a LD_PRELOAD wrapper that turns isatty() into a
function that returns true if its arg is 1.
4) perl -pi -e 's/isatty/fchdir/g' myapp
(might not work ;).
--
Stephane
More information about the Python-list
mailing list