我更习惯Unix脚本。
findstr "ORA-[0-9]" alert_%%A.log>>%output-file%
在Unix中,我可以捕获返回错误:
if [ $? -ne 0 ]; then
echo "there is no ORA-ERROR found on alert log" > $ERRLOG
问题:我如何在DOS/批处理文件中做到这一点?
如果命令失败,%errorlevel%
变量返回errorlevel
(使用.bat
扩展,而使用.cmd
扩展,即使命令成功,它也会更改errorlevel
)。
if %errorlevel% neq 0 echo There is no ORA-ERROR found in alert log > %ERRLOG%
注意:
我很确定以美元符号($
)进行的事情是变量,所以我制作了它输出到变量的文件。
希望对你有帮助。