How can I read streaming output of a subprocess

Kiuhnm kiuhnm03.4t.yahoo.it
Wed May 2 07:46:09 EDT 2012


On 5/2/2012 13:08, Damjan Georgievski wrote:
> I want to read the stream of an external process that I start with 
> Python. From what I've seen that's not possible with the subprocess module?

Try with
    cmd = 'your command here'
    stdout = Popen(cmd, shell = True, stdout = PIPE, stderr = STDOUT).stdout
    print(stdout.read())
just to see if it works.
You can also use
    for line in stdout:
        print(line)
or similar.

Then you should add some error checking, etc...

Kiuhnm



More information about the Python-list mailing list