Python scripts and return codes
Tim Peters
tim_one at email.msn.com
Fri Sep 8 17:32:58 EDT 2000
[Gunars Lucans]
> I had tried sys.exit(rc) a few days ago and I'd swear it didn't
> return anything but zero back to the shell. That was on a Win98
> system with version 1.5.2 or 1.6b1. Right now, with 2.0b1 on NT4,
> it works like a charm. I'll try to pin down where I went wrong
> before.
On Win98SE:
C:\Python20>python
Python 2.0b1 (#4, Sep 7 2000, 02:40:55) [MSC 32 bit (Intel)] on win32
Type "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.exit(3)
C:\Python20>if errorlevel 0 echo yup
yup
C:\Python20>if errorlevel 1 echo yup
yup
C:\Python20>if errorlevel 2 echo yup
yup
C:\Python20>if errorlevel 3 echo yup
yup
C:\Python20>if errorlevel 4 echo yup
C:\Python20>
Perhaps you're thinking of os.system(). Due to the brain-damaged
command.com on Win95 and Win98, os.system() *always* returns 0 under Win9x
(but not under NT, which uses the less brain-damaged cmd.exe as its shell).
More information about the Python-list
mailing list