views:

59

answers:

2

here are sample lines

Apr  9 11:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred
some other log lines ..
....
Apr  9 12:53:26 skip [2244]: [2244] ab-cd-ef:cc [INFO] A recoverable error has occurred

now the LATEST line would have to be one with the latest Date String, and THAT is the one that needs to be printed, plus the NEXT time the parser runs on the log file, somehow the previous LATEST line has to be compared with the Existing latest one, and it CAN e the case, that NOTHING Changed and the OLD line is STILL the latest one, OR there is a NEW line, but ONLY the NEW log line should be printed and NOT if there is NO NEW log Entry.

A: 

Assuming typical logfile always log the info in sequential time order where the latest data will always printout later in the file, then you can just iterate over your logfile and put your info in Hash/associated array with the log string as key and the log timestamp as entry.

By the time you finish with the file, the entry should contain the last time the wanted log info was printed.

DJ
A: 

Hi DJ, You are absolutely right regarding getting the last line containing the text string, but the caveat is as follows: 1. What if the parsing script runs and there is NO new entry, in that case, do Nothing. 2. If there IS a NEW line with a LATER time stamp containing the Search String, in that case, EMAIL the Latest. and HENCE lies the Dilemma, that we need to STORE the previous line and then compare the Date String of the lines every time the script runs and ONLY email the last line containing the String, IF it has a time signature greater than the one before.

I apologize if i was not clear. I am also working on the solution and will post it here as soon as i am done. Thanks,

kamal