Handling exit code returned by python in shell script

后端 未结 3 1470
萌比男神i
萌比男神i 2020-12-10 04:23

I am calling a python script from within a shell script. The python script returns error codes in case of failures.

How do I handle these error codes in shell scrip

3条回答
  •  醉酒成梦
    2020-12-10 04:50

    The exit code of last command is contained in $?.

    Use below pseudo code:

    python myPythonScript.py
    ret=$?
    if [ $ret -ne 0 ]; then
         #Handle failure
         #exit if required
    fi
    

提交回复
热议问题