Python Forum
How to get program output from subprocess.Popen? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: How to get program output from subprocess.Popen? (/thread-29117.html)



How to get program output from subprocess.Popen? - glestwid - Aug-18-2020

Hi,

I need to run a standalone app from my Python 3.7.3 script in a separate window, wait its completion and after that parse its output in my script. How can I have it done in my Python script?


RE: How to get program output from subprocess.Popen? - buran - Aug-19-2020

you can use convenient subprocess.run() and pass capture_output=True. e.g.

import subprocess
result = subprocess.run(['ls'], capture_output=True) # running linux ls command
print(result.stdout.decode())