Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBscript output not writing correctly

Status
Not open for further replies.

Hun9865

Technical User
Oct 23, 2012
23
GB
Hello Scripting Experts,

I have a log file on remote servers.. in remote servers c:\vb\text.log

I have included my remote systems in list.Txt
like
Code:
server1
server2
below is the sample of log..

Code:
application working
[10/23/2012 working

[10/24/2012 nos appdown
error found you need to check this
.

Below is my Script
Code:
Set Fso = CreateObject("Scripting.FileSystemObject")
Set InFile = fso.OpenTextFile("list.Txt")
Set out = fso.CreateTextFile("error.log")


    Const ForReading = 1
    Do While Not (InFile.atEndOfStream)
      strComputer = InFile.ReadLine
      today = Date()
      Set fso = CreateObject("Scripting.FileSystemObject")
      strFilePath = "\\" & strComputer & "\c$\vb\"

      Set InputFile = fso.OpenTextFile(strFilePath & "text.log", 1)
      Do While Not (InputFile.AtEndOfStream)
      strLine = InputFile.ReadLine

      If Left(line, Len(today)+1) = "[" & today Then
          ' line timestamped with today's date
              If InStr(line, "nos") > 0 Then
                    ' line contains "error"
                          out.WriteLine InStr & vbTab & strComputer
                              End If
                                End If
        Loop
      InputFile.close

    Loop

    out.Close
    InFile.Close

Basically the above script should search from current date line only from the text.log file "that is [10/24/2012 nos appdown". then if found as "Nos" in the current datet line.. then it should write to the error.log with computer Name.

In my case the output is not comming , however looks like it is searching for the string "Nos".

Kindly gail break me from this situation....
 
Code:
...
      If Left([!]strLine[/!], Len(today)+1) = "[" & today Then
      ' line timestamped with today's date
        If InStr([!]strLine[/!], "nos") > 0 Then
        ' line contains "error"
          out.WriteLine [!]strLine[/!] & vbTab & strComputer
        End If
      End If
...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top