Zithen Posted October 29, 2006 Share Posted October 29, 2006 trying to read a bunch of log files and get some blocks from it. what i need to do it capture the error blocks then pull certin information from the blocks to vars. getting the info into the vars have been extreamly difficult and not sure if its due to i suck with stringregexp or how the errors are displated in the log. here is a example of the error blocks ~-----------------------------------------------------------------~ | Error : Scan failed | | Descrip : error in scan Suberr : 4d | ~-----------------------------------------------------------------~ | More info : Scan number : 31 scans failed : 12 | ~-----------------------------------------------------------------~ another type ~-----------------------------------------------------------------~ | Error : Scan failed | | Descrip : error in scan Suberr : 4d | ~-----------------------------------------------------------------~ | More info : Scan number : 31 scans failed : 12 | ~-----------------------------------------------------------------~ | More info2 : Scan : 1 failed : 1 | | Error Code 4 | ~-----------------------------------------------------------------~ some have more info in them some have less. What i have been getting when trying to do this is it will start one get some info then put the rest in other and miss some info. not all look exactly the same some have more info some dont. In short looking for a start on what would be the good way to go about doing this. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 29, 2006 Moderators Share Posted October 29, 2006 trying to read a bunch of log files and get some blocks from it. what i need to do it capture the error blocks then pull certin information from the blocks to vars. getting the info into the vars have been extreamly difficult and not sure if its due to i suck with stringregexp or how the errors are displated in the log. here is a example of the error blocks ~-----------------------------------------------------------------~ | Error : Scan failed | | Descrip : error in scan Suberr : 4d | ~-----------------------------------------------------------------~ | More info : Scan number : 31 scans failed : 12 | ~-----------------------------------------------------------------~ another type ~-----------------------------------------------------------------~ | Error : Scan failed | | Descrip : error in scan Suberr : 4d | ~-----------------------------------------------------------------~ | More info : Scan number : 31 scans failed : 12 | ~-----------------------------------------------------------------~ | More info2 : Scan : 1 failed : 1 | | Error Code 4 | ~-----------------------------------------------------------------~ some have more info in them some have less. What i have been getting when trying to do this is it will start one get some info then put the rest in other and miss some info. not all look exactly the same some have more info some dont. In short looking for a start on what would be the good way to go about doing this.Do you have an actual txt file you can upload (this has all your blocks of example in it)? Do you have what the preferred "out" file would look like? (upload both) Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Zithen Posted October 30, 2006 Author Share Posted October 30, 2006 attached is the file that has there look. i just modified there names but look is exact to what is in the logs. for the output just could be anything i guess just standard listed down starting with the error as its name..i am going to make a gui front end to it, kinda like a db view when all is said and done for examp for the first one attached scan failed error in scan - 4d scan failed ....and so on..err.txt Link to comment Share on other sites More sharing options...
CoderDunn Posted October 30, 2006 Share Posted October 30, 2006 (edited) This will read the "Error" field. expandcollapse popup$Read_Field = "Error" $Read_File = @ScriptDir & "\" & "Test.txt" $Open_File = FileOpen($Read_File,0) If $Open_File = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf ; Find $Read_Field in file $Current_Read = "" While StringInStr($Current_Read,$Read_Field) = 0 $Current_Read &= FileRead($Open_File,1) If @error = -1 Then MsgBox(0,"error","Unable to find field.") Exit EndIf WEnd ; Find the colon after $Read_Field $Current_Read = "" While StringInStr($Current_Read,":") = 0 $Current_Read &= FileRead($Open_File,1) If @error = -1 Then MsgBox(0,"error","Unable to find field.") Exit EndIf WEnd ; Read the data until it reaches the pipe that signifies end of line $Current_Read = "" While StringInStr($Current_Read,"|") = 0 $Current_Read &= FileRead($Open_File,1) If @error = -1 Then MsgBox(0,"error","Unable to find field.") Exit EndIf WEnd ; Remove the pipe from end of string $Current_Read = StringTrimRight($Current_Read,1) ; Remove White spaces at start and end of data $Current_Read = StringStripWS($Current_Read,3) MsgBox(0,"","The field """ & $Read_Field & """ contains: """ & $Current_Read & '"') Hallman Woot 100 posts Edited October 30, 2006 by Hallman Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted October 30, 2006 Moderators Share Posted October 30, 2006 Sorry I didn't respond earlier, I would look at StringRegExp() to see if it can do what you want... an example might be something like:#include <array.au3> $Array = StringRegExp(FileRead('C:\test.txt'), '(?s)(?i)Suberr\s*\:\s*(.*?)\s', 3) _ArrayDisplay($Array, '')#include <array.au3> is only to use the _ArrayDisplay() so you can see the return. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now