I'm a Python noob.
Is there a way to get the STDOUT and STDERR of all running processes in Python? Some processes exit after a long time and their status is constantly being written to STDOUT.
I'm a Python noob.
Is there a way to get the STDOUT and STDERR of all running processes in Python? Some processes exit after a long time and their status is constantly being written to STDOUT.
To get subprocess output line by line without waiting for it to close:
p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
while True:
o = p.stdout.readline()
if not o:
break
print o
you can use p.stdout.read(n) if want to read every 'n' characters from the process.
Hope this helps.