Sign in to follow this  
Followers 0
Sub

Text string search for updating file

2 posts in this topic

#1 ·  Posted (edited)

I have a server that is constantly updating a log file and I wanted to be notified when the server was having these specific errors. The log file would be updated with an error message for example " 06:51:55: Error 201 ". The first part is the time stamp and the second is the error obviously. My first question is, can Autoit read text files that are constantly being updated or in use like a log file? So I need to search the last line of this log file and then show a general message box pop up to notify me that an error has occurred. Another problem is that the error can happen twice in a row so I will get the same message but with a different time stamp and I dont know anything about coding the RegExp to check if the same message has occurred but with a different time stamp.

So I need to search a text file

Wait for an " XX:XX:XX: Error 201 "

Message Box pop up

Wait for a different " YY:YY:YY: Error 201 "

Message Box pop up

Can anyone give me some help on how to start doing this? This is just an example to start me off coding this, I may need to check for a 2nd type of error and use Cases for which message box to display later on.

Edited by Sub

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

FileReadLine()

StringLeft()

Are the basic functions you need.

$LastLine = FileReadLine("filepath.log", -1) ;Read the last line
$LastTime = StringLeft("$LastLine",8) ; Read first 8 chars of last line
Edited by JohnOne

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0