#!/usr/bin/perl -w use strict; use Digest::MD5; my @fileary; $fileary[0] = { name => '<file>', + oldhash => '', newhash => '' }; $fileary[1] = { name => '<file>', oldhash => '', newhash => '' }; while (1) { foreach (@fileary) { # move the newhash (from last iteration) to the oldhash of # this iteration %{$_}->{oldhash}=%{$_}->{newhash}; #check to see if there is a different has to #last iteration if (%{$_}->{newhash} ne %{$_}->{oldhash}) { print "File ".%{$_}->{name}." has changed\n"; } else { print "oldhash: ".%{$_}->{oldhash}.". newhash: ". %{$_}->{n +ewhash}."\n"; } #go get a filehandle open (FILE, %{$_}->{name}) or die "Can't open '$_': $!"; #go get the hash of the file %{$_}->{newhash} =Digest::MD5->new->addfile(*FILE)->hexdigest; close FILE; } }
Its not very scalable, however you could dynamically create your hash of arrays from a config file.
If youre going to run it as a daemon i would suggest a wait/sleep time, and sending an alert to something like NetX/pager/SMS/email etc....
In reply to Re: Log's and MD5 Hashes: UPDATE
by Ryszard
in thread Log's and MD5 Hashes
by satanklawz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |