スケジュールされたバッチ ファイルによって毎日開始されるプロセスがあります。エラーが発生した場合にプロセスを再起動するには、エラー処理を組み込む必要があります。ほとんどの場合、すべてがうまく機能しますが、月に1回程度タイムアウトエラーが発生するのは避けられません. プロセスはエラーレベルを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.