我有一个调用 Perl 脚本文件的 DOS 批处理文件:
ssutexec.pl prog=MyProg I_CARD=MyCard O_F071=ME007 F70P=MYF70P TRIG=MYTRIG
set status=%errorlevel%
if NOT %status% == 0 (
echo *******************************************************
echo MPSBM070 JOB stopped with a RETURN CODE of %status%
echo ************** END OF JOB *****************************
goto JobEnd
)
在 ssutexec.pl perl 脚本文件中,执行了一个错误条件,脚本以 exit($status) 退出:
if ($status != 0)
{
system("ssutdttm.pl SSUTEXEC \"finished processing $prog_nam (Abnormal End) on\"") ;
print "******************************************************************" ;
print " JOB STOPPED - Due to Return code of ($status)" ;
print "*****************END OF JOB***************************************" ;
system("ssutdttm.pl SSUTEXEC \"finished processing $prog_nam (Abnormal End) on\"") ;
system("ssuttmdr.pl -c -b $starttime -m \"$prog_nam\"") ;
exit($status) ;
}
我不是 perl 脚本专家。没有触发错误级别,所以我没有收到错误。如何在我的 DOS 批处理文件中捕获 perl 脚本退出代码的值?
包含编辑:新的批处理文件如下所示:
@echo off
setlocal enabledelayedexpansion
if not defined run_env goto ScriptExit
echo ******************************************************************
echo * MYPROG *
echo ******************************************************************
perl ssutdttm.pl MYPROG Start -
perl ssutexec.pl prog=MyProg I_CARD=MyCard O_F071=ME007 F70P=MYF70P TRIG=MYTRIG
set status=!errorlevel!
if NOT %status% == 0 (
echo *******************************************************
echo MYPROG JOB stopped with a RETURN CODE of %status%
echo ************** END OF JOB *****************************
goto JobEnd
)
:JobEnd
if %status% == 0 (
echo *******************************************************
echo NORMAL END OF JOB - RETURN CODE of %status%
echo ******** NORMAL END OF JOB ****************************
) ELSE (
echo !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
echo ABNORMAL END OF JOB - RETURN CODE of %status%
echo !!!!!! ABNORMAL END OF JOB !!!!!!!!!!!!!!!!!!!!!!!!!!!!
)
ssutdttm.pl MYPROG end -
exit /b %status%
::
:ScriptExit
echo run_env: %run_env%