Python Forum
How to get program output from subprocess.Popen?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get program output from subprocess.Popen?
#1
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?
Reply
#2
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())
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Information subprocess.Popen() suddenly giving me grief? davecotter 3 529 Dec-13-2023, 10:49 PM
Last Post: davecotter
  merge two csv files into output.csv using Subprocess mg24 9 1,687 Dec-11-2022, 09:58 PM
Last Post: Larz60+
  Use subprocess.Popen and time.sleep chucky831 2 1,890 Aug-11-2022, 07:53 PM
Last Post: carecavoador
  UnicodeEncodeError caused by print when program runs from Popen SheeppOSU 5 2,845 Jan-13-2022, 08:11 AM
Last Post: SheeppOSU
  Subprocess.Popen() not working when reading file path from csv file herwin 13 14,615 May-07-2021, 03:26 PM
Last Post: herwin
  Did subprocess.Popen() causes main routine to pause stdout? liudr 4 3,551 May-04-2021, 08:58 PM
Last Post: liudr
  disable subprocess.popen prompt echo paul18fr 1 1,966 Feb-04-2021, 02:50 AM
Last Post: Larz60+
  how to pass the interactive string to Popen subprocess maiya 1 1,845 Sep-18-2020, 09:36 PM
Last Post: Larz60+
  waiting for barcode scanner output, while main program continues to run lightframe109 3 4,579 Sep-03-2020, 02:19 PM
Last Post: DeaD_EyE
  how can we record a video file from our program output (moving object) Zhaleh 0 1,778 Aug-03-2020, 02:47 PM
Last Post: Zhaleh

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020