1

e:\ logs \ action.logに保存されたリモートコンピューター(50台のサーバーのリスト)に以下のテキストがありますこのaction.logには日付と時刻が含まれ、実行されたアクションが追跡され、日付と時刻が追加されます.....そして次の行には、機能している、機能していないなどのアクションが関連付けられます。

サンプルのaction.logファイルテキスト....。

[10/15/2012 09:33:56:248 qwe rtd] {some text will be there here}

this time it is working on the task and taken: 2.31 seconds

[10/15/2012 09:34:55:248 qwe rtd] {some text will be there here}

this time it is working on the task and taken: 3.31 seconds

[10/16/2012 09:33:56:248 qwe rtd] {some text will be there here}

this time it is working on the task and taken: 2.31 seconds

[10/16/2012 09:34:55:248 qwe rtd] {some text will be there here}

this time it is working on the task and taken: 3.31 seconds

[10/16/2012 09:34:55:248 qwe rtd] {you got error}
You got error as file missing..

現在の日付からaction.logを読み取るスクリプトを探しています(上記の例の日付の今日の日付は2012年10月16日です)。また、「エラーが発生しました」または「ファイルが見つからないためエラーが発生しました。」というテキストが見つかった場合は、サーバー名に続いてExcelまたはテキストファイルに出力します。

(基本的な基準は、現在の日付のテキストのみを検索することです....過去のエラーは無効であるため...)フォーラムからスクリプトを探しています....私はスクリプトを初めて使用します......

4

1 に答える 1

0

次のようなものを試してください。

computer = CreateObject("WScript.Network").ComputerName

today = Right("0" & Month(Date), 2) & "/" & Right("0", Day(Date), 2) & "/" _
  & Year(Date)

Set fso = CreateObject("Scripting.FileSystemObject")

Set in  = fso.OpenTextFile("action.log", 1)
Set out = fso.OpenTextFile("error.log", 2)

Do Until in.AtEndOfStream
  line = in.ReadLine
  If Left(line, Len(today)+1) = "[" & today Then
    ' line timestamped with today's date
    If InStr(line, "error") > 0 Then
      ' line contains "error"
      out.WriteLine line & vbTab & in.ReadLine & vbTab & computer
    End If
  End If
Loop

in.Close
out.Close
于 2012-10-17T09:06:59.480 に答える