【问题标题】:Log read only at current date with error append to text file as output日志在当前日期只读,错误附加到文本文件作为输出
【发布时间】:2012-10-17 02:19:57
【问题描述】:

我在远程计算机上有以下文本(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 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(上面示例日期中的今天日期是 10/16/2012)。如果发现任何文本称为“你有错误”或“文件丢失错误..”然后输出后跟服务器名称到 excel 或文本文件。

(基本标准是仅搜索当前日期文本......因为过去的错误无效......) 从论坛寻找一些脚本......我是脚本新手......

【问题讨论】:

    标签: scripting vbscript automation batch-file


    【解决方案1】:

    试试这样的:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-22
      • 1970-01-01
      • 1970-01-01
      • 2011-05-26
      • 1970-01-01
      • 1970-01-01
      • 2012-10-24
      • 2016-11-06
      相关资源
      最近更新 更多