Jason S
Jason S

Reputation: 189786

python + win32: simple way to run a process and print its error code?

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

Answers (2)

aodj
aodj

Reputation: 2353

Subprocess has all your answers

>>> import subprocess
>>> command = ['foo.exe', 'arg1', 'arg2']
>>> process = subprocess.Popen(command, shell=True)

Upvotes: 1

Jason S
Jason S

Reputation: 189786

never mind, found it in the subprocess module:

 import subprocess;
 retcode = subprocess.call(["ls","-l"])

Upvotes: 5

Related Questions