Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3218246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:30:20+00:00 2026-05-17T15:30:20+00:00

When I execute a python script using subprocess.Popen(script, shell=True) in another python script, is

  • 0

When I execute a python script using subprocess.Popen(script, shell=True) in another python script, is it possible to alert python when the script completes running before executing other functions?

On a side note, can I get real-time output of the executed python script?
I can only get output from it doing command>output.txt but that’s only after the whole process ends. stdout does not grep any ouput.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:30:20+00:00Added an answer on May 17, 2026 at 3:30 pm

    When you create a subprocess with Popen, it returns a subprocess.Popen object that has several methods for accessing subprocess status and data:

    • You can use poll() to determine whether a subprocess has finished. None indicates that the process has ended.
    • Output from a script while its running can be retrieved with communicate().

    You can combine these two to create a script that monitors output from a subprocess and waits until its ready as follows:

    import subprocess
    
    p = subprocess.Popen((["python", "script.py"]), stdout=subprocess.PIPE)
    
    while p.poll() is None:
        (stdout, stderr) = p.communicate()
        print stdout
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a python script that uses subprocess.Popen to execute two programs (from compiled
Is it possible to execute a python-script on a server without using something like
How do I execute the following shell command using the Python subprocess module? echo
I'm using a shell execute action in rsyslog to a python script on a
I have the following query that I'm executing using a Python script (by using
I have a python based tkinter script which executes some commands using subprocess module.
I am using os.system to execute a java program through a python script. I
My application has a button to execute a python script dynamically using execfile .
I am running a Tkinter GUI that spins off another process (python script) with
I'm having a strange issue when using subprocess.Popen.communicate(). For background, I want to execute

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.