0

I have used subprocess to obtain the output from command line, but it requires the process to end before you can use the data. Is there a way to get data line by line as it outputs? I need to have a process running indefinitely while python gets each new line as it is printed out.

Aeolus
  • 996
  • 1
  • 8
  • 22
  • 1
    Possible duplicate of [live output from subprocess command](https://stackoverflow.com/questions/18421757/live-output-from-subprocess-command) – ahota Nov 12 '18 at 03:56

1 Answers1

0

If you know the Process ID or PID, You can do subprocess.call('tail -f /proc/<pid>/fd/1')

Piyush Singh
  • 2,736
  • 10
  • 26