在 Korn shell 中,我调用了一个 python 程序,并将所有内容都记录到 $workfile:
python3 crontab_search.py | tee $workfile
在 Python 程序 crontab_search.py 中,我以返回码退出:
sys.exit(1)
如果我移除 T 恤,我会得到正确的返回码,但我无法使用 T 恤获取代码。
这有效:
python3 crontab_search.py; echo $? | tee $workfile
但这不起作用:
python3 crontab_search.py; returncode=$? | tee $workfile
我想根据 returncode 的值做一些额外的事情。
谢谢。