Repost: Read a running process output

Ashok Prabhu ashokprabhuv at gmail.com
Fri Feb 5 12:57:17 CET 2010


Hi,

I very badly need this to work. I have been googling out for a week
with no significant solution. I open a process p1 which does keeps
running for 4+ hours. It gives some output in stdout now and then. I
open this process with subprocess.Popen and redirect the stdout to
PIPE. However when I read the output with readline it blocks waiting
forever. I need to read from p1.stdout till what it has in the PIPE.
Can someone help me out with the exact code change that can accomplish
the task.

from subprocess import *

p1=Popen('/usr/sunvts/bin/64/vtsk -d',stdout=PIPE,shell=True)

while 1:
    line=p1.stdout.readline()
    print line

Thanks in advance,
~Ashok.



More information about the Python-list mailing list