Python scripts and return codes

Tim Peters tim_one at email.msn.com
Fri Sep 8 16:14:49 EDT 2000


[Gunars Lucans]
> Is it possible for a Python script to send a return code back to the shell
> that's running it?  Yes, I know I should be doing it all in
> Python :-), but I'm
> trying to add a Python-based util to an existing shell script (on
> a Win platform
> with a MKS Korn shell).

>>> import sys
>>> print sys.exit.__doc__
exit([status])

Exit the interpreter by raising SystemExit(status).
If the status is omitted or None, it defaults to zero (i.e., success).
If the status numeric, it will be used as the system exit status.
If it is another kind of object, it will be printed and the system
exit status will be one (i.e., failure).
>>>

So, e.g., sys.exit(5)






More information about the Python-list mailing list