Thread Unterschiedliche MD5 Ergebnisse (35 answers)
Opened by Rambo at 2006-05-11 18:46

Rambo
 2006-05-17 19:37
#66010 #66010
User since
2003-08-14
803 Artikel
BenutzerIn

user image
Hallo noch mal allerseits,

ich habe das Script jetzt noch ein klein wenig verändert und
komme bei einem Problem nicht weiter.
Es werden alle Dateien in allen Verzeichnissen durchsucht und
die Checksum berechnet was ja OK ist. Leider rechnet er aber
auch die Checksum für Verzeichnisse und Unterverzeichnisse
was ja nicht ganz so viel Sinn mach.
Wo muss ich änderungen vornehmen damit es funktioniert?
Code: (dl )
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
use strict;
use Digest::MD5;
use File::Find;
use threads;
use threads::shared;
#
#
# ------------------------------------------------------------------
# get time
# ------------------------------------------------------------------
my @time        = localtime();
my $time_string = sprintf "%02d.%02d.%02d",
         $time[5]+1900, $time[4]+1, $time[3],
         $time[2], $time[1], $time[0];
#
#
# ------------------------------------------------------------------
# threads component
# ------------------------------------------------------------------
my $StopDotPrintFlag : shared;
sub DotPrintThread
  {
   my ($Interval, @Trash) = @_;
   use IO::Handle;
   autoflush STDOUT 1;
   my $IntervalCount=0;
   while ($StopDotPrintFlag != 2)
        {
         if ($StopDotPrintFlag == 1)
           {
             print STDOUT ".";
           }
         $IntervalCount++;
         sleep $Interval;
        }
         return $IntervalCount;
  }
#
#
# ------------------------------------------------------------------
# file details
# ------------------------------------------------------------------
my $directory = '.';
my $result_file = "md5_check_$time_string\.txt";
unlink ("$result_file");
#
my @files;
find(\&get_dir,$directory);
#
print "\n\tMD5_CHECK.PL powered by R.Hehlert\n";
#
#
# ------------------------------------------------------------------
# start threads
# ------------------------------------------------------------------
$StopDotPrintFlag = 0;
my $Interval = 1;
print "\n\tStarting 0% [";
my $DotPrintThread = threads->new(\&DotPrintThread, $Interval);
$StopDotPrintFlag = 1;
#
#
# ------------------------------------------------------------------
# start main programm
# ------------------------------------------------------------------
for my $file(@files)
  {
   my $md5 = Digest::MD5->new;
   open FILE, $file;
   binmode(FILE);
   while (<FILE>)
        { $md5->add($_);
        }
    my $digest = $md5->hexdigest;
  close FILE;
          open(my $fh, ">>$result_file") or die $!;
          print $fh "Digest is $digest for $file\n";
          close $fh;
        }
#
#
# ------------------------------------------------------------------
# stop threads
# ------------------------------------------------------------------
$StopDotPrintFlag = 2;
my $NumberOfPrintedDots=$DotPrintThread->join;
print "\t] 100% applied time was ".$NumberOfPrintedDots*$Interval." seconds\n";
print "\n\tPls. read $result_file for results\n";
#
#
# ------------------------------------------------------------------
# get all files from all directorys
# ------------------------------------------------------------------
sub get_dir
  {
   push (@files,$File::Find::name);
  }
#  
#END


Danke auch noch mal an Gwen fürs einstellen.

Merci

Gruss Rambo

View full thread Unterschiedliche MD5 Ergebnisse