2
在Korn shell中,我有一個python程序的調用,我記錄一切$工作文件:從Python腳本獲取退出代碼與重定向輸出
python3 crontab_search.py | tee $workfile
在Python程序crontab_search.py,我退出與返回代碼:
sys.exit(1)
如果我刪除三通,我得到正確的返回碼,但我無法得到與三通的代碼。
這工作:
python3 crontab_search.py; echo $? | tee $workfile
但是,這並不工作:
python3 crontab_search.py; returncode=$? | tee $workfile
我想要做的基於返回碼的值一些額外的東西。
謝謝。
感謝您的參考。該頁面上有很多。我在Solaris上的Korn shell中工作,並且不支持pipefail。我確實得到了這個工作:returncode = $({{python3 ./crontab_search.py; echo $?>&3;} | {tee ./$workfile>/dev/null;}} 3>&1)謝謝! – user2565827