×
UNIX.COM Login
Username:
Password:  
Show Password






👤


SHA1 verification script

OS X (Apple)




Kindly Note - This is a Single User Post by Forum Member Ardzii Regarding:
SHA1 verification script.
Please Follow The Primary Link Above to View the Full Discussion.

   
Old 02-15-2017
Ardzii Ardzii is offline
Registered User
 
Join Date: Dec 2016
Last Activity: 24 February 2017, 7:52 AM EST
Posts: 19
Thanks: 19
Thanked 0 Times in 0 Posts
Apple SHA1 verification script

Hi guys!

Me again! ...
I'm trying to build (on MacOS directly) a bash script that will help me verify a SHA1 digest (to verify downloads and so on and so forth).

So first off, here's my version of BASH under OSX:


Code:
bash-4.4$

And here's my version of Sierra (macOS):


Code:
10.12.3 (16D32)

and last but not least, here's my code:



Code:
#!/usr/local/bin/bash

declare sha1=""
declare PATH=""
declare verifySha=""

echo
echo
echo
echo " Please enter the path to the file you want to check:"
read PATH
echo
echo " Now the SHA1 provided by the publisher:"
read sha1
echo
echo
verifySha=$(openssl sha1 $PATH)
if [ $sha1 -eq $verifySha ]
then
        echo "OK, same here!"
        echo
        echo
else
        echo "Not the same, try again!"
        echo
        echo
fi



Now, I know that $sha1 and $verifySha will not be the same for now... I need a sed in the middle to extract the sha signature.
But, aside from this minor problem that I will fix soon, I get the error:


Code:
./shaVerif.sh: line 17: openssl: command not found
./shaVerif.sh: line 18: [: 7798b65ae8842768bd2ff068545e0a3fc2dd0140: unary operator expected

Anyone has any idea why the openssl command does not work in a bash script? (Obviously, when I try to pass the command outside of the script, it works!).