checking a burned CD against an ISO

Sy Ali sy1234-Re5JQEeQqe8AvxtiuMwx3w at public.gmane.org
Wed May 23 03:55:47 UTC 2007


Because of some odd issue with k3b not verifying a burned disk, I went
ahead and explored a better way to compare the disk.  Thanks to some
earlier advice I already had the groundwork, but I wanted to make
things a bit easier.

So I came up with the following script.

It seems to work fine - and both works and fails under the correct
circumstances.. but is there anything which anyone here would change
to make for less cutting-and-pasting or cleaner/happier code?


ISO_FILENAME=pclinuxos-2007.iso
MD5_FILENAME=pclinuxos-2007.md5sum
DEVICE=/dev/dvd

# SOURCE_MD5=`md5sum $ISO_FILENAME`
SOURCE_MD5=`cat $MD5_FILENAME`
# Remove the trailing filename
SOURCE_MD5=`echo $SOURCE_MD5 | sed "s/$ISO_FILENAME$//"`

FILESIZE=$(stat -c%s "$ISO_FILENAME")
DISK_MD5=`dd if=$DEVICE | head -c $FILESIZE | md5sum`
# Remove the trailing hyphon
DISK_MD5=`echo $DISK_MD5 | sed "s/-$//"`

echo ""
echo ""
echo ""
if [ $SOURCE_MD5 = $DISK_MD5 ]; then
   echo "$ISO_FILENAME: OK"
else
   echo "Sorry, your disk is not ok"
   echo "I checked $ISO_FILENAME against $MD5_FILENAME"
   echo ""
   echo "md5sum was $SOURCE_MD5"
   echo "cd sum was $DISK_MD5"
fi
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list