5 Einträge, 1 Seite |
Gast+2007-08-17 17:41:37--aber es geht nicht !
1
2
3
4
5
6
7
8
9
10
11
Or we can use the addfile method for more efficient reading of the file:
use Digest::MD5;
my $file = shift || "/etc/passwd";
open(FILE, $file) or die "Can't open '$file': $!";
binmode(FILE);
print Digest::MD5->new->addfile(*FILE)->hexdigest, " $file\n";
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#!/usr/bin/perl use warnings; use strict; use Digest::MD5; my $su = 'be90385edbb12bf9982932902f10c4d5'; open(FILE, "/bin/su"); # nervig .oO my $md5 = Digest::MD5->new; while (<FILE>) { $md5->add($_); } close(FILE); if($md5->hexdigest ne $su) { print "Warning, files were modified :/\n"; } else { print "No modification :)\n"; }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
#!/usr/bin/perl use warnings; use strict; use File::stat; my $file = '/bin/su'; my $oldtime = 'Sun Apr 23 08:48:54 2006'; my $sb = stat($file) || die "something went wrong :/"; my $newtime = scalar localtime $sb->mtime; if($newtime ne $oldtime) { print "Warning, file was modified!\n"; } else { print "no modification\n"; }
5 Einträge, 1 Seite |