I have a Python script which will do some actions, and depending on the result, will exit with a code 0 (all right) or 1 (not good).
I want to catch this result, store it into a variable and send it over UDP. This cannot be done inside the Python script (requirement).
So let's say my script is something like:
import sys
# Do some stuff
sys.exit(0) # or sys.exit(1)
Which I run with python script.py
.
How can I get this exit status code (0 or 1)?
I try to echo $errorlevel
, but it only prints a blank line. I also try to use exit(0)
instead of sys.exit()
(see here) and some other unsuccessful attempts.