Reputation: 189786
I'm running Windows XP and want to run a process and print its exit code. I don't have a C compiler, nor do I want to use one. I do have Python though, so I figure it's probably the easiest way to do this.
How can I write a quick python script to run a process and print its exit code?
Upvotes: 0
Views: 260
Reputation: 2353
Subprocess has all your answers
>>> import subprocess
>>> command = ['foo.exe', 'arg1', 'arg2']
>>> process = subprocess.Popen(command, shell=True)
Upvotes: 1
Reputation: 189786
never mind, found it in the subprocess module:
import subprocess;
retcode = subprocess.call(["ls","-l"])
Upvotes: 5