ajtsystems
IS-IT--Management
Hi,
I have a requirement to search through an error log for a string. I am using some monitoring software to look for errors in a file but the file name will change. E.G from error12052010.log to error13052010.log over night.
I have the code to search through a static file name but need it to handle changes
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "hello"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\test\string.txt", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
Wscript.Echo 0
Else Wscript.Echo 1
End If
Loop
I was thinking that maybe the file name needs a date function but I am not sure teh date format in VBscripot is the same as the format of the file I need to check
I have a requirement to search through an error log for a string. I am using some monitoring software to look for errors in a file but the file name will change. E.G from error12052010.log to error13052010.log over night.
I have the code to search through a static file name but need it to handle changes
Const ForReading = 1
Set objRegEx = CreateObject("VBScript.RegExp")
objRegEx.Pattern = "hello"
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("c:\test\string.txt", ForReading)
Do Until objFile.AtEndOfStream
strSearchString = objFile.ReadLine
Set colMatches = objRegEx.Execute(strSearchString)
If colMatches.Count > 0 Then
Wscript.Echo 0
Else Wscript.Echo 1
End If
Loop
I was thinking that maybe the file name needs a date function but I am not sure teh date format in VBscripot is the same as the format of the file I need to check