[an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] 24x7 Script Archive


Scanning program log file for errors

Dim buffer, string
Dim position, number
Dim err_found, boolean

// Load the log file into memory
FileReadAll ("program.log", buffer)
// Convert to lower case to find all sorts of errors
Lower (buffer, buffer)
// Search for word "error"
Pos (buffer, "error", 1, position)
// If error found, notify system administrator
IsGreater (position, 0, err_found)
If (err_found, NOTIFY, END)

NOTIFY:
// Send email message
MailSend( "Exchange Settings", "syspassword", "admin@mycompany.com", "Error occurred while running PROGRAM.EXE. See program log file for details." )

END:
// Done