[英]Error capture of perl script in shell
我試圖捕獲perl腳本的實際錯誤(如果失敗)。 並且它沒有停止,並且下一個腳本被觸發。
更新的 Python腳本運行良好,僅對perl腳本有問題
if ! perl test.pl arg2 arg1 ;
then
echo "Error running test.pl in Preparing data for algorithm; rest of process stopped." >&2 >>$LOG_PATH/Perl_RUN_$TRACK_TIME
elif ! python themes.py;
then
echo "Error running themes.py rest of process stopped." >&2 >>$LOG_PATH/Python_RUN_$feed_name'_'$TRACK_TIME
elif ! python $SCRIPT_PATH/pre_survey_dt.py;
then
echo "Error running pre_survey_dt.py rest of process stopped." >&2 >>$LOG_PATH/Python_RUN_$TRACK_TIME
fi
請告知我這里缺少的內容。
if ! perl test.pl arg2 arg1; then
echo "test.pl failed with error code $?" >&2
exit 1
fi
使用return
而不是exit
:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.