I'm running a python program on WindowsXP. How can I obtain the exit code after my program ends?
-
how are you planning to do this?SilentGhost– SilentGhost2009-09-29 10:45:12 +00:00Commented Sep 29, 2009 at 10:45
-
1@phoenix24 you should go back to questions you have previously asked and mark the right ones as answered. Your acceptance rating is quite low. 44%Spooks– Spooks2011-10-04 14:25:35 +00:00Commented Oct 4, 2011 at 14:25
Add a comment
|
4 Answers
How do you run the program?
Exit in python with sys.exit(1)
If you're in CMD or a BAT file you can access the variable %ERRORLEVEL% to obtain the exit code.
For example (batch file):
IF ERRORLEVEL 1 GOTO LABEL
1 Comment
David Sykes
IF ERRORLEVEL 1 will match exit codes of >= 1 - support.microsoft.com/kb/69576
If you want to use ERRORLEVEL (as opposed to %ERRORLEVEL%) to check for a specific exit value use
IF ERRORLEVEL <N> IF NOT ERRORLEVEL <N+1> <COMMAND>
For example
IF ERRORLEVEL 3 IF NOT ERRORLEVEL 4 GOTO LABEL