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!

Extract information from a log file and display them into a list

Status
Not open for further replies.

cippall

IS-IT--Management
Feb 3, 2009
5
AU
I need help to display inside an HTA data from a log file. The text of the log file is something like this(Job_Name_Log.txt)


12/20/2009 3:18:05 AM;
Softaware install location: C:\Program Files\Software\
12/20/2009 3:18:05 AM; Software file being executed: C:\Project Location\001.softextension
12/20/2009 3:18:05 AM; Some comment
12/20/2009 3:21:44 AM; Job Complete
12/20/2009 3:21:45 AM; Job Completed Successfully
12/20/2009 3:18:05 AM;
Softaware install location: C:\Program Files\Software\
12/20/2009 3:18:05 AM; Software file being executed: C:\Project Location\002.softextension
12/20/2009 3:18:05 AM; Some comment
12/20/2009 3:21:44 AM; Job Complete
12/20/2009 3:21:45 AM; Job Completed With Errors
12/20/2009 3:18:05 AM;
Softaware install location: C:\Program Files\Software\
12/20/2009 3:18:05 AM; Software file being executed: C:\Project Location\003.softextension
12/20/2009 3:18:05 AM; Some comment(only 4 lines if the users close the application before job is completed)
12/20/2009 3:18:05 AM;
Softaware install location: C:\Program Files\Software\
12/20/2009 3:18:05 AM; Software file being executed: C:\Project Location\004.softextension
12/20/2009 3:18:05 AM; Some comment
12/20/2009 3:21:44 AM; Job Complete
12/20/2009 3:21:45 AM; Job Completed Successfully


I want to display in two lists with select options the name of the jobs that were completed successfully and jobs that were completed with errors, something like this:



Job Completed Successfully
C:\Project Location\001.softextension
C:\Project Location\004.softextension


Job Completed With Errors
C:\Project Location\002.softextension
C:\Project Location\003.softextension








 
Code:
set objFSO = CreateObject("Scripting.FileSystemObject")
set objShell = CreateObject("WScript.Shell")

set objLogFile = objFSO.OpenTextFile("filename.ext", 1)

do while NOT objLogFile.AtEndOfStream
	strLine = objLogFile.ReadLine
	if (inStr(strLine, "Software file being executed")) then
		if (strSoftware <> "" ) AND (boolJobStatusDefined = false) then	strErrors = strErrors & strSoftware & vbNewLine
		strSoftware = right(strLine, inStrRev(strLine, ":\") - 2)
		boolJobStatusDefined = false
	end if
	
	if (inStr(strLine, "Job Completed Successfully")) then strSuccess = strSuccess & strSoftware & vbNewLine : boolJobStatusDefined = true
	if (inStr(strLine, "Job Completed With Errors")) then strErrors = strErrors & strSoftware & vbNewLine : boolJobStatusDefined = true
loop

msgbox "Success: " & vbNewLine & strSuccess
msgbox "Errors: " & vbNewLine & strErrors
[\code]

-Geates
 
oops

Code:
strSoftware = right(strLine, len(strLine) - inStrRev(strLine, ":\") + 2)

should replace
Code:
strSoftware = right(strLine, inStrRev(strLine, ":\") - 2)

-Geates

 
Excellent! Well done sir! Sorry for the long delay...didn't had enough time to check this before. Thank you for your help!

Cheers!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top