Thread checken, ob ein datei geändert wurde (4 answers)
Opened by Gast at 2007-08-17 19:41

RPerl
 2007-08-17 22:53
#98356 #98356
User since
2006-11-26
384 Artikel
BenutzerIn

user image
Code (perl): (dl )
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";
}


Vielleicht hilft dir ja das.

oder das?

Code (perl): (dl )
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";
}

View full thread checken, ob ein datei geändert wurde