How to Check MD5 Sum the easy way

How to do things, solutions, recipes, tutorials
Message
Author
GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

How to Check MD5 Sum the easy way

#1 Post by GeoW »

Update: Wolf Pup has made a .pet for this.

I am putting this update at the top of my original post because it
makes installation even easier than before - much easier. The .pet
does everything in the instructions for you. My instructions serve
only historical purposes now.

First - test the current behavior. Find an md5 or md5.txt file and click
on it. It opens as text - right, not too useful. Close the text window.

Five mouse clicks to install the new behavior:
1. Click on the link below
2. Select "Open it with the default application (petget)"
3. Click "OK"
4. Click "Install Package"
5. Click "OKAY"

http://puppylinux.ca/tpp/bugs/geow_md5_checker-1.5.pet

Now, the next time you reboot or restart the X server, you will have
the new behavior - click on an md5 or md5.txt file and it will check the iso.

If you have followed the preceding instructions and installed the .pet you are done.
-----------------------------------------------------------------------------------------------------

My original post follows. It has been updated each time changes
have been made. You do not need to read it.


However, feel free to read it. I suggest the following purposes:
A) To see how this behavior is implemented
B) As an example of scripting ( good ? / bad ? )
C) To see what a stubborn amateur scripter can accomplish ( it took
me days to get this running ).
Enjoy!


I have weak typing skills so I am very dependent
on Puppy's GUI.

I download and test every new version of Puppy
that comes out. I always download the MD5 file
and check that the iso download was successful.

I really do not like typing the long filenames like:
puppy-4.1alpha6-uniproc-ide-conservative-seamonkey.iso.md5.txt

The following set of fairly minor additions allow
me to do the md5 check with a single mouse click.

First, one or more of the following lines needs to
be added to the end of

/usr/share/mime/globs

Code: Select all

application/gwbckmd5:*.md5
application/gwbckmd5:*.md5.txt
application/gwbckmd5:*.md5sum
They will allow you to set the Run Time Action for
these file types without affecting text files in general.

Second, these two small scripts need to be in the PATH

Code: Select all

#!/bin/sh 
#        gwbckmd5   GWB  15 Sep 2008

rxvt -bg black -fg green -T "GWB Checking MD5 Sum" -g 100x10  -e gwbckmd5-2 "$1"

# end    gwbckmd5

Code: Select all

#         gwbckmd5-2   GWB  15 Sep 2008

# echo $1
# echo
dir1=`dirname "$1"`
# echo $dir1

cd "$dir1"

# echo
# echo working dir is now `pwd`
# echo

echo
echo md5sum -c "$1"
echo

md5sum -c "$1"

if [ $? = 0 ]; then
   echo
   echo -e '\033[1;32mSUCCESS\033[0m'
else
   echo
   echo -e '\033[1;31mERROR\033[0m'
fi

echo
echo -n Press "<Enter>" to close this window.

read ch1

#  end       gwbckmd5-2 

Third and final, find an md5 or md5.txt file,
right click on it, Set run action, and in the
box labeled "Enter a shell command:"
add gwbckmd5 to the front
the result should be: gwbckmd5 "$@"

Select the second radio button at the top:
Only for the type `application/
gwbckmd5'(application/gwbckmd5)


Click: Use Command

That's it, now you should be able to click
on md5 or md5.txt files and have the iso checked.

Hope this is useful,

GeoW
Last edited by GeoW on Thu 18 Sep 2008, 20:27, edited 7 times in total.

davec51
Posts: 530
Joined: Thu 13 Apr 2006, 22:31
Location: Virginia

A Not-So-Easy Way

#2 Post by davec51 »

This is an elegant solution, but as one who would as soon do the Fiji Firewalk as mess with code, here's what I do to ease the checking of md5sum's:
I can't get long filenames right, either, so before checking, I rename the file, from, say"puppy4.2alpha_seamonkey_doesn't_work_anyway.iso" to "pup.iso" Then the checking is easy, and I'm going to delete the .iso file anyway after burning, so what's the difference?

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

#3 Post by GeoW »

Effective! But I keep the isos and the md5s.

I just pull out the files I need to run frugally,
but the rest are there in the iso if I ever want
to burn a cd.

User avatar
Lobster
Official Crustacean
Posts: 15522
Joined: Wed 04 May 2005, 06:06
Location: Paradox Realm
Contact:

#4 Post by Lobster »

Thanks - would be great in Puppy :)

I use Menu / Internet / pwget
to download files
(open help to read why)
:oops: I must admit I never use md5sum unless
getting a faulty download, which never seems to happen . . .

Depends on connection. When I used browsers to download
(Opera was the most reliable) I needed md5sum
Puppy Raspup 8.2Final 8)
Puppy Links Page http://www.smokey01.com/bruceb/puppy.html :D

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

Updated

#5 Post by GeoW »

The two scripts have been updated.

This is mainly for Windows escapees, like me, who still have
files in "My Downloads"

GeoW

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#6 Post by Pizzasgood »

For the record, you can ease the burden of typing long names and paths in two simple ways:

A: Start typing the name and press [Tab] and Bash will try to auto-complete. If it can't, press [Tab] a second time and it will list the possible choices. You could then copy-paste it in (select and then middle-click) or type a little more and try again.

B: Select the file in ROX-Filer (the file manager). Then open a terminal and type whatever you need to type. When you get to the part that needs the path, middle-click to paste it in. Note: this doesn't escape any spaces in the path, so you may want to use a quotation mark before and after. It also uses the absolute path, and that is not always desirable.


As for one-click MD5 sum checking, I did something similar recently. I just hadn't gotten around to uploading it yet. Basically the procedure is the same as yours, but I only have one script named md5sumX, which looks like this:

Code: Select all

#!/bin/sh
#checks a md5sum list and displays a dialog indicating the result
#2008-08-18  Pizzasgood

cd "$(getdir "$1")"
RES="$(md5sum -c "$1")"
if [ $? = 0 ]; then
	Xdialog --title 'MD5SUM Check' --icon /usr/share/midi-icons/ok.xpm --msgbox "$RES" 0 0
else
	Xdialog --title 'MD5SUM Check' --icon /usr/share/midi-icons/error.xpm --msgbox "$RES" 0 0
fi
I set that as the run-action for the .md5 files and then when I click them, not only do I get a graphical list but I also get a bright red or green visual confirmation as to whether they matched or not.

The drawbacks with my version are that with very long lists of files, it won't be able to fit them on the screen and doesn't scroll, and you can't copy-paste things out of it.

Also, it may be worth setting up mimetypes for the .md5sum extension. I don't see that very often but I think it does turn up once in a while.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

koolie
Posts: 518
Joined: Mon 12 Mar 2007, 06:38

#7 Post by koolie »

Here's another option.
http://wareseeker.com/Software-Developm ... zip/241835

OK, don't hit me.
If you are running Win concurrently in VirtualBox, it is no trouble to use it.
Maybe it runs in Wine. Dunno.
I do know that it is neat, and I sometimes use it in Win.

It is open-source. Maybe it could be ported.

Another option is to use k3b. I haven't tried it yet, but see here...
http://ubuntuforums.org/showthread.php?t=625962

HTH.

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

#8 Post by ttuuxxx »

The easiest way is with this application
http://www.murga-linux.com/puppy/viewto ... 73&t=32700
I think it should be a default application in puppy, since its so small and straight forward:)
ttuuxxx
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

Update - Now Available as a .pet

#9 Post by GeoW »

Wolf Pup has created a .pet that completely implements the md5
checker. It now takes 5 mouse clicks to install and 1 click to use.

I have updated the instructions in my original post.

GeoW

koolie
Posts: 518
Joined: Mon 12 Mar 2007, 06:38

#10 Post by koolie »

Unfortnately, it doesn't do it for me, with any file I try, on Puppy 4.00.
Anyone got any suggestions?
Attachments
md5checkererror.jpg
(56.55 KiB) Downloaded 526 times

koolie
Posts: 518
Joined: Mon 12 Mar 2007, 06:38

#11 Post by koolie »

@ttuuxxx,
That's a really neat gadget.
I didn't realise that there were so many hash types.

Not wanting to denegrate it 'tho, winmd5sum is still my favourite because it will check the file's md5sum against the text md5sum and report correct or otherwise, without you having to study the output in detail.

If someone ports this to Linux, it would be the best little checker by far, IMHO.

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

#12 Post by GeoW »

Yo koolie,

It is unclear to me what you are doing.

It looks like you are somehow running it on itself. I have never seen
i run on anything but an md5 or md5.txt file before. You seem to be
running it on its own .pet file. I cannot imagine how you got it to do that.

koolie
Not wanting to denegrate it 'tho, winmd5sum is still my favourite because it will check the file's md5sum against the text md5sum and report correct or otherwise, without you having to study the output in detail.

If someone ports this to Linux, it would be the best little checker by far, IMHO.
That is exactly what my script does!

You are supposed to click on an md5 file in a folder that also contains
the iso to be checked.


GeoW

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

#13 Post by GeoW »

Yo Lobster,

Thank you for the kind words. If my scripts actually make it into Puppy,
it will be my first code type contribution in almost 20 years.

I got Puppy running last December ( using the Lin'N'WinNewB system )
with no previous Linux or Unix experience. Less than a year on the
internet under Windows XP Pro (SP2) convinced me I needed to escape.

Before January 2007, I had been away from computers for a long time.

I wanted to contribute to the effort, but with no knowledge of Linux or
bash I had to content myself with testing, making bug reports, offering
advice, etc.

I have finally created something useful! I like the way this script works
so much I have checked all my available md5 sums - most of them
more than once.

If this script is seen to be useful, I will be happy.

GeoW

koolie
Posts: 518
Joined: Mon 12 Mar 2007, 06:38

#14 Post by koolie »

@GeoW,

Thanks for pointing out that it has to be run on the text file.
Having not read the instructions, I just used it the same way as other hash checkers.

You will be rewarded in heaven.

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

#15 Post by GeoW »

koolie,

You are welcome.

Not in any hurry for that reward.

Something to look forward to though.

GeoW

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

#16 Post by GeoW »

Yo Pizzasgood,

Thanks for your post. I often learn from reading what you write. and
this is no exception.

I have tested your script - it works beautifully. I will need to study it to
learn some new commands.

However - I like mine better - not for the reasons you stated:
scrolling and copy/paste. I like mine better for the following reason:

You seem to be using the standard philosophy of "do it and report".
I think, the first time I ran your script, I ended up with several
instances. The lack of any immediate response made me think my
mouse click had not been recognized.

My script immediately opens a window and lists the command being
executed. That way the user knows he has been heard, and knows
what he is waiting for.

I do not think it costs anything extra to do it this way.

By the way - when I first started using Puppy, I used to regularly get
several instances of help or seamonkey - maybe I need to work on
my patience.

To the rest of you:

Has anyone tried my script and liked it?
I had intended to add a useful feature -
not start a competition.


GeoW

Wolf Pup
Posts: 637
Joined: Fri 28 Apr 2006, 01:37

#17 Post by Wolf Pup »

I liked the script. :)
[img]http://img230.imageshack.us/img230/8595/ubd6467dp2.png[/img]
[url=http://www.tinyurl.com/54tu74]Visit The Repository[/url] - Helpful and hard-to-find treats for Puppy 3.
[url=http://www.tinyurl.com/c5a68f]Click Here for Puppy Support Chat, + Helpful Links.[/url]

User avatar
Pizzasgood
Posts: 6183
Joined: Wed 04 May 2005, 20:28
Location: Knoxville, TN, USA

#18 Post by Pizzasgood »

Yep, mine calculates the sums first, then displays them. My computer is fast enough that doing that with a Puppy sized file only takes two and a half seconds or so. I mostly check smaller files though, like a 10 mb file, or a collection of ten files that are all in the sub-megabyte range. So for those it just pops up right away.

The main reasoning behind my method was to have a color signify success or failure. My eyes were very tired when I wrote that, between working a summer job involving mostly computer work, coming home and spending much time on the computer, and recently getting new glasses. I wanted something I could just glance at without having to focus or read.


I think it wouldn't be very hard to take your on-the-fly method and have it followed up by a big red or green "SUCCESS" or "ERROR" message.

Something like this:

Code: Select all

md5sum -c "$1" 
if [ $? = 0 ]; then
   echo -e '\033[1;32mSUCCESS\033[0m'
else
   echo -e '\033[1;32mERROR\033[0m'
fi

EDIT: I always set my terminals to be white text on a black background. I have no idea how this would look on Puppy's default black-on-white. Probably pretty nasty. It looks nice on a black background though.
[size=75]Between depriving a man of one hour from his life and depriving him of his life there exists only a difference of degree. --Muad'Dib[/size]
[img]http://www.browserloadofcoolness.com/sig.png[/img]

User avatar
ttuuxxx
Posts: 11171
Joined: Sat 05 May 2007, 10:00
Location: Ontario Canada,Sydney Australia
Contact:

#19 Post by ttuuxxx »

The nice thing about the gtkhash program that I posted links to on the page 1, Its quick and doesn't have any problems with large compressed files with lots folders/files in it.
I just tar.gz my Libs folder that I have on puppylinux.ca
extracted it was 870MB compressed it was 270mb with 2214 items in the Libs directory, I used the gtkhash program and 2 seconds later I had the md5 55e9ef9305c4d97b5d00cd20dce9af17
Pretty good and straight forward. Also you save the the md5 file output as text, under file/save
ttuuxxx
http://audio.online-convert.com/ <-- excellent site
http://samples.mplayerhq.hu/A-codecs/ <-- Codec Test Files
http://html5games.com/ <-- excellent HTML5 games :)

GeoW
Posts: 150
Joined: Tue 01 Jan 2008, 00:25
Location: New Jersey, USA ( East Coast )

Updated With Pizzasgood's Suggestions

#20 Post by GeoW »

Yo Pizzasgood,

I have updated my mimetypes and scripts in the top post to incorporate
all your suggested improvements. I needed to tinker a little to get the
"Error" to come out in red. I couldn't find documentation so I just poked
at numbers until I found the one that controlled the color.

Wolf Pup incorporated the changes into an updated .pet.

I have updated the url in the top post to point to the new .pet.

GeoW

Post Reply