Wanting to learn a little about perl and needing to check the md5sums on
newly downloaded iso files from redhat, I wrote this script to read the
md5sums file and check the md5sums on all the files found in the current
directory named in the md5sums file.
Perl guru comments welcome if I have done something poorly or not at all
that I should have done.
#!/usr/bin/perl
#printsums
#run from the directory that contains the iso files and the md5sums file
from redhat
#this script reads the md5sums file, runs md5sum on the files if exists
in the
#current directory and compares the calculated checksums with that
contained in the md5sums
#file
# Bret Hughes [EMAIL PROTECTED] April 15, 2000
open (SUMS,"md5sums");
while (<SUMS>){ #this example places the line read into the
default scaler $_
($sum, $file)=split /\s+/; #here the default scaler is
being passed to split
if ( -f $file){
print "\nCalculating md5 checksum for file $file\n";
print "This will take a while... be patient\n" ;
($calcsum,$rest)=split /\s+/,`md5sum --binary $file`;
if ( $calcsum == $sum){
print "Checksum for $file ok\n\n";
}
else{
print "\n****** ERROR ******\n";
print "Checksums do not match for $file \n\n ";
}
}
else {
print "$file not in current directory ... skipping\n\n"
}
}
--
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.