0

The follwing python script works fine, exept that the shell window remains open.

file = open("C:\\Documents and Settings\\User1\\Desktop\\BPanel\BadePanel\\SteelUsage.bsu", "a+")
input = raw_input("Please enter project name:")
input = input.upper ()
for line in file.readlines():
        if input in line:
            print "Project name already exists, executing BadePanel"
            import time
            time.sleep(4)
            import subprocess
            subprocess.call(['C:\\Documents and Settings\\User1\\Desktop\\BPanel\BadePanel\\BadePanel.exe'])
            exit(subprocess)
file.write (input+"\n")
print "Project name written to file, executing BadePanel"
import time
time.sleep(4)
import subprocess
subprocess.call(['C:\\Documents and Settings\\User1\\Desktop\\BPanel\BadePanel\\BadePanel.exe'])
exit(subprocess)
file.close()

The shell window terminates ony after i close the exeuted progrm (BadePanel.exe)
I would like the script to display the printed text in the shell window, wait 4 secs, execute the program, and then exit.
Thanks

1
  • 1) provide a minimal example 2) read the manual. Commented Jun 15, 2016 at 15:46

1 Answer 1

1

From the doc:

subprocess.call()

Run the command described by args. Wait for command to complete, then return the returncode attribute.

So the .call() function only ever returns after BadePanael.exe finishes.

Instead, try:

print "Project name written to file, executing BadePanel"
time.sleep(4)
subprocess.Popen(['C:\\Documents and Settings\\User1\\Desktop\\BPanel\BadePanel\\BadePanel.exe'])
sys.exit(0)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.