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:
bash-4.4$
And here's my version of Sierra (macOS):
10.12.3 (16D32)
and last but not least, here's my 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:
./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!).