[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


Watching for file changes

// This is an example of "file change watch" job. Regular "file watch" job checks
// file presence only. In some situations, you may need to run a job only when
// a change occurs.

// This scripts uses "change.txt" file to store "watch file" attributes between runs.

Dim buffer, string
Dim file_time, string
Dim file_date, string
Dim date_time, datetime
Dim buffer2, string
Dim no_change, boolean

// Read parameter file into buffer
FileReadAll( "change.txt", buffer )

// Get watch file date/time
FileTime( "k:\data\account.dat", file_time )
FileDate( "k:\data\account.dat", file_date )
DateTime( file_date, file_time, date_time )
// Convert to string
Format( date_time, "mm/dd/yyyy hh:mm:ss", buffer2 )
// Compare file times
isEqual( buffer, buffer2, no_change )

// If the file date/time is the same, then nothing to do, else
// update parameter file and perform main job
If( no_change, END, UPDATE )
END:
Exit

UPDATE:
FileSave( "change.txt", buffer2 )
// do main job here
// ...