2012-10-17 17 views
1

我在e:\ logs \ action.log中保存了遠程計算機(50臺服務器的列表)以下的文本 此action.log將包含a日期&時間和執行的動作將被跟蹤並追加日期&時間.....下一行將會有像工作,不工作相關的操作 每次...在當前日期只讀日誌,並將錯誤附加到文本文件作爲輸出

樣品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.. 

腳本我正在尋找腳本來閱讀活動從當前日期開始n.log(上述示例日期中的今天的日期爲2012年10月10日)。如果發現任何文本稱爲「你有錯誤」或「錯誤爲文件丟失..」,然後輸出服務器名稱爲Excel或文本文件。

(基本標準是搜索當前日期文本....因爲過去的錯誤是無效的......) 尋找一些腳本從論壇....我是一個新的腳本... ...

回答

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 
+0

謝謝你..它應該工作.....尚未測試......但你拿到了鑰匙,,,, – user1751790

相關問題