简体   繁体   English

在Shell中捕获Perl脚本时出错

[英]Error capture of perl script in shell

I am trying to captuer the actual error of the perl script if it fails. 我试图捕获perl脚本的实际错误(如果失败)。 And its not stopping and the next script is getting triggered. 并且它没有停止,并且下一个脚本被触发。

UPDATED Python scripts are running fine only having problem with the perl script 更新的 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

Please advice what I am missing here. 请告知我这里缺少的内容。

if ! perl test.pl arg2 arg1; then
    echo "test.pl failed with error code $?" >&2
    exit 1
fi

Use return instead of exit : 使用return而不是exit

  • to return from a shell function. 从shell函数返回。
  • to exit from a shell script that has been sourced. 从已获取的Shell脚本退出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM