In order to calculate the SHA1 checksum of a downloaded file, I could type

/usr/bin/openssl sha1

in Terminal and then drag there the file which I want check. To make it simpler, one could enable a Context Menu item for this action.

What is the best way to create such item in Mac OS X 10.6? A detailed answer is appreciated, because I don't have good experience with AppleScript, etc.


Step by step

  1. Open Automator
  2. Create new service
  3. Choose to receive selected Files and Folders in Finder
  4. Add action Run Shell Script where your bash command is /usr/bin/openssl sha1 "$@" and you pass input as arguments

How can I get the output? Preferably in a Growl pop-up or a message window/dialog.

link|improve this question

79% accept rate
feedback

2 Answers

up vote 2 down vote accepted
  1. Open Automator
  2. Create new service
  3. Choose to receive selected Files and Folders in Finder (note: this actually won't work too well on folders...)
  4. Add action Run Shell Script, set Shell to /bin/bash and Pass input to "as arguments", and enter this script:

    for file; do
        if [[ -d "$file" ]]; then
            echo "$(basename "$file") is a directory"
        else
            cd "$(dirname "$file")"
            /usr/bin/openssl sha1 "$(basename "$file")"
        fi
    done | tr "\n" "\r"
    
  5. Add action Run Applescript, and enter this script:

    on run {input, parameters}
        tell application "System Events"
            activate
            display dialog input buttons {"OK"} default button 1
        end tell
    end run
    
  6. Save the service with a descriptive name

link|improve this answer
Great! Thank you, Gordon. – Andrei May 11 '10 at 16:49
feedback

http://www.macworld.com/article/142601/2009/09/makeaservice.html

link|improve this answer
3  
I'm tempted to vote you up because you're right but that's not a detailed answer... – Josh May 9 '10 at 23:13
Links don't work for me, so I explicitly asked for a detailed answer. I have tried to make a service in automator for Run Shell Script and View Results but I don't see any results and actually now even Context Menu item has disappeared. I guess something was wrong. – Andrei May 10 '10 at 7:35
I'm sorry that a step-by-step tutorial isn't detailed enough for you, but that sounds like a personal problem to me. – Hasaan Chop May 10 '10 at 14:23
This was also very helpful. Thanks a lot. – Andrei May 11 '10 at 16:34
3  
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.