2

I'm trying to use the subprocess.Popen() command to run a command and capture its output.

from subprocess import Popen, PIPE
output = Popen(args, stdout=PIPE)
output.communicate()

The problem here is that output.communicate() only returns when the program I'm running as args finishes, and returns all the output at once. In fact, the program takes several minutes to run and outputs results line by line.

Any way I can capture the line by line results as they happen, instead of waiting to capture all the output at once?

Thanks,

leontp587
  • 699
  • 1
  • 6
  • 19
  • related: [Python: read streaming input from subprocess.communicate()](http://stackoverflow.com/a/17698359/4279) – jfs May 31 '15 at 16:35

0 Answers0