Running a command line program and reading the result as it runs
Ian Simcock
Ian.Simcock at Internode.on.net
Thu Aug 22 11:26:32 EDT 2013
Chris Angelico wrote:
> Is the program actually producing output progressively? I just tried
> your exact code with "dir /ad /s /b" and it worked fine, producing
> output while the dir was still spinning (obviously setting shell=True
> to make that work, but I don't think that'll make a difference). It
> may be that pip buffers its output. Is there a parameter to pip to
> make it pipe-compatible?
>
> ChrisA
>
If I run pip in the command window I can see it's output appearing line
by line rather than on one block.
I tried the code with the dir command but it's too fast for me to be
sure if it's working or not.
I tried again using the command "ping google.com" instead since I know
that output's slowly and it something that everyone should have. In the
command window I can see that the output appears over time, but from
python I get nothing for a while and then suddenly get all the output in
one rapid go.
Can you think of anything else I can look at?
Ian Simcock.
More information about the Python-list
mailing list