checking a burned CD against an ISO
Chris F.A. Johnson
cfaj-uVmiyxGBW52XDw4h08c5KA at public.gmane.org
Wed May 23 04:26:18 UTC 2007
On Tue, 22 May 2007, Sy Ali wrote:
> 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
I'd use command-line parameters:
ISO_FILENAME=$1
MD5_FILENAME=$2
> DEVICE=/dev/dvd
>
> # SOURCE_MD5=`md5sum $ISO_FILENAME`
> SOURCE_MD5=`cat $MD5_FILENAME`
No need for an external command:
read SOURCE_MD5 < $MD5_FILENAME
> # Remove the trailing filename
> SOURCE_MD5=`echo $SOURCE_MD5 | sed "s/$ISO_FILENAME$//"`
No need for an external command:
SOURCE_MD5=${SOURCE_MD5%% *}
Or combine both commands:
read SOURCE_MD5 junk < "$MD5_FILENAME"
> FILESIZE=$(stat -c%s "$ISO_FILENAME")
> DISK_MD5=`dd if=$DEVICE | head -c $FILESIZE | md5sum`
No need for more than one external command:
DISK_MD5=$( md5sum "$DEVICE" )
> # Remove the trailing hyphon
> DISK_MD5=`echo $DISK_MD5 | sed "s/-$//"`
No need for an external command:
DISK_MD5=${DISK_MD5%-}
> echo ""
> echo ""
> echo ""
Only one command is needed:
printf "\n\n\n"
> 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
--
Chris F.A. Johnson <http://cfaj.freeshell.org>
========= Do not reply to the From: address; use Reply-To: ========
Author:
Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)
--
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