Dim FileSystemObj
Dim NotepadObj,strLine,objFile
Dim ResultFilePath,sSearchMsg
REM Arguments Form Command Propmt
If WScript.Arguments.Count = 1 Then
sSearchMsg = WScript.Arguments.Item(0)
Else
sSearchMsg ="FAIL"
End If
REM For log File and Result File Creattion.
ResultFilePath ="D:\Automation Results\LatestResults.txt"
Set FileSystemObj = CreateObject("Scripting.FileSystemObject")
Set ResultdObj =FileSystemObj.CreateTextFile(ResultFilePath)
ResultdObj.Close
ReadDataFromTextFile("\\BD07860A\DDrive\rpm_scripts\TestResults\Status.log")
ReadDataFromTextFile("\\blrd1497\D\rpm_scripts\TestResults\Status.log")
ReadDataFromTextFile("\\vmlancer\D\rpm_scripts\TestResults\Status.log")
REM ResultdObj.Close
Function ReadDataFromTextFile(InputFile)
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objDictionary = CreateObject("Scripting.Dictionary")
Set objTextFile = FileSystemObj.OpenTextFile(ResultFilePath,8)
Const ForReading = 1
Set objFile = objFSO.OpenTextFile (InputFile, ForReading)
i = 0
Do Until objFile.AtEndOfStream
strNextLine = objFile.Readline
If strNextLine <> "" Then
IF InStr(strNextLine, sSearchMsg)Then
objDictionary.Add i, strNextLine
End If
End If
i = i + 1
Loop
objFile.Close
objTextFile.WriteLine("*****START LOG Machine :" & InputFile &"******************************")
objTextFile.WriteLine(" ")
objTextFile.WriteLine(" ")
For Each strLine in objDictionary.Items
objTextFile.WriteLine(strLine)
Next
objTextFile.WriteLine("*****END LOG Machine :" & InputFile &"******************************")
objTextFile.WriteLine(" ")
objTextFile.WriteLine(" ")
objTextFile.Close
End Function
No comments:
Post a Comment