I have python program, which is running from shell. When there is an error in python, it will exit with exit(1) or something else, and I need shell program to get that answer, if there is error, run this program again.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- How to get the return code of a shell script in lu
- Evil ctypes hack in python
The exit code can be found in the $? See the example:
There is nothing special about Python in this case. You capture the exit code as with any other program:
$?
where you have this code directly, as in sanyi's answer, oryou embed the program call in an
if
orwhile
condition, where its non-zero-ness is checked: