gpt4 book ai didi

error-handling - BAT : Parse Output File For Error Handling

转载 作者:行者123 更新时间:2023-12-03 07:51:01 25 4
gpt4 key购买 nike

我有一个计划的批处理文件每天都会启动的过程。如果有错误,我需要内置错误处理才能重启进程。所有这些在大多数情况下都有效,但是我每个月都会收到一次超时错误,所以这是不可避免的。该进程不会将错误级别输出到bat文件,因此我需要能够解析输出文件以确定该进程是否需要重新启动。

我尝试使用FOR /F函数将第12行的内容作为变量传递给IF语句,但我一直没有成功。我显然可以跳到第12行,但是接下来我要处理其余各行的标记。有人有我可以尝试的建议吗?

一切正常时输出文件:

(添加行号以提高可读性)

1  Pricing Script
2
3 ________________________________________________________________________
4
5 Retrieve Prices
6
7 Date of price file: 070912
8 Regular only
9 Connecting to server intdata.com
10 TCP/IP connection established
11
12 TySymb Interactive Data
+400 more lines

出现错误时的输出文件:
1  Pricing Script
2
3 ________________________________________________________________________
4
5 Retrieve Prices
6
7 Date of price file: 071012
8 Regular only
9 Connecting to server intdata.com
10 TCP/IP connection established
11 Time Out
12 General Time Out. The User ID and/or Password might be incorrect.

最佳答案

我只是使用FIND或FINDSTR在输出中查找错误消息。我不用担心行号。

find "General Time Out. The User ID and/or Password might be incorrect." "yourFile.log" && (
echo Timeout occurred, you must put code here to restart
)

要么
findstr /c:"General Time Out. The User ID and/or Password might be incorrect." "yourFile.log" && (
echo Timeout occurred, you must put code here to restart
)

关于error-handling - BAT : Parse Output File For Error Handling,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11437306/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com