仅记录在当前日期读取错误追加到文本文件作为输出 [英] Log read only at current date with error append to text file as output
问题描述
我看看下面保存在电子远程计算机上的文本(50个服务器的列表):\\日志\\ ACTION.LOG
这ACTION.LOG将包含一个Date&安培;时间和执行的动作将被跟踪并追加日期和放大器每一次;时间.....和下一行将具有操作
像工作相关的,没有工作......
I Have below text on remote computers (a list of 50 servers) saved in e:\logs\action.log This action.log will contain the a Date & time and every time a action performed will be tracked and appends the date & time..... and the next line will have the action associated like working, not working...
样ACTION.LOG文件中的文本.....
Sample action.log file text.....
[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脚本(今天的日期在上面的例子日期是二○一二年十月一十六日)。如果发现任何所谓的文字你有错误或错误的文件丢失..,然后输出后跟服务器名称到Excel或文本文件。
The script I am looking for a script to read the action.log from the current date (todays date in the above example date is 10/16/2012). And if found any text called "you got error" or "error as file missing.." then output followed by server Name to a excel or a text file.
(基本标准是只对当前日期的文本搜索....为过去的错误是无效的......)
寻找从论坛的一些脚本....我是新来脚本......
(the Basic criteria is to search on current date text only.... as past errors are not valid...) Looking for some script from forum.... I am a new to scripting......
推荐答案
尝试是这样的:
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
这篇关于仅记录在当前日期读取错误追加到文本文件作为输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!