Scripting 当前日期的日志只读,错误附加到文本文件作为输出
我在远程计算机上有一个50台服务器的列表,保存在e:\logs\action.log中 此action.log将包含日期和时间,每次执行的操作都将被跟踪并附加日期和时间。。。。。下一行将有动作 我喜欢工作,不喜欢工作 示例action.log文件文本Scripting 当前日期的日志只读,错误附加到文本文件作为输出,scripting,vbscript,automation,batch-file,Scripting,Vbscript,Automation,Batch File,我在远程计算机上有一个50台服务器的列表,保存在e:\logs\action.log中 此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 second
[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或文本文件
基本条件是只搜索当前日期文本。。。。由于过去的错误无效。。。
从论坛寻找一些脚本。。。。我是一个新的脚本编写者……尝试以下内容:
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