I'm new to Bash and want to catch my Python script exit code.
My script.py looks like:
#! /usr/bin/python
def foofoo():
ret = # Do logic
if ret != 0:
print repr(ret) + 'number of errors'
sys.exit(1)
else:
print 'NO ERRORS!!!!'
sys.exit(0)
def main(argv):
# Do main stuff
foofoo()
if __main__ == "__main__":
main(sys.argv[1:]
My Bash script:
#!/bin/bash
python script.py -a a1 -b a2 -c a3
if [ $?!=0 ];
then
echo "exit 1"
fi
echo "EXIT 0"
My problem is that I am always getting exit 1 printed in my Bash script. How can I get my Python exit code in my Bash script?