1.在shell脚本执行python脚本时,需要通过python脚本的返回值来判断后面程序要执行的命令
例:有两个py程序 hello.py
def main(): print "Hello"if __name__=='__main__': main() world.py
def main(): print "Hello"
if __name__=='__main__': main()
python hello.py python world.py
hello world
hello.py这样写
import sysdef main(): try: print "hello" sys.exit(0) except: sys.exit(1)
if __name__=='__main__': main()
shell 脚本改为
python hello.py if [ $?==0 ];then exit else python world.py fi