prolifix23
IS-IT--Management
I am trying to do this:
I have two files:
1. Application Log file
2. Txt file having search strings
I have to read the txt file get the search strings and search for them in the application log file. When a match is found I want to write the line containing the string onto a variable.
This script will run every 2 mins, so when it starts the second time it should start from where it left the first time.
Please help !!! I need this urgently. I am new to VBScript. With whatever I was able to make out I have done this.
***********************************************************
Sub Main
Option Explicit
'On Error Resume Next
Dim objFSO, objFile, objFile1, objDict, strLine
Const ForReading = 1
Const ForAppending = 8
Set objDict = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile1 = objFSO.OpenTextFile("c:\temp\remaining.txt", ForAppending, True)
Set objFile = objFSO.OpenTextFile("c:\IIS.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If Not objDict.Exists(strLine) Then
objDict.Add strLine, ""
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("c:\IIS.log", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If objDict.Exists(strLine) Then
objfile1.writeline(strLine)
End If
Loop
objFile.Close
End Sub
***********************************************************
Please let me know how to accomplish this.
Thanks in advance.
I have two files:
1. Application Log file
2. Txt file having search strings
I have to read the txt file get the search strings and search for them in the application log file. When a match is found I want to write the line containing the string onto a variable.
This script will run every 2 mins, so when it starts the second time it should start from where it left the first time.
Please help !!! I need this urgently. I am new to VBScript. With whatever I was able to make out I have done this.
***********************************************************
Sub Main
Option Explicit
'On Error Resume Next
Dim objFSO, objFile, objFile1, objDict, strLine
Const ForReading = 1
Const ForAppending = 8
Set objDict = CreateObject("Scripting.Dictionary")
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile1 = objFSO.OpenTextFile("c:\temp\remaining.txt", ForAppending, True)
Set objFile = objFSO.OpenTextFile("c:\IIS.txt", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If Not objDict.Exists(strLine) Then
objDict.Add strLine, ""
End If
Loop
objFile.Close
Set objFile = objFSO.OpenTextFile("c:\IIS.log", ForReading)
Do Until objFile.AtEndOfStream
strLine = objFile.ReadLine
If objDict.Exists(strLine) Then
objfile1.writeline(strLine)
End If
Loop
objFile.Close
End Sub
***********************************************************
Please let me know how to accomplish this.
Thanks in advance.