I'm rather new to bash scripting, and Google isn't as useful as I'd like for this. I'm just playing around with a little password entry program in my .bash_profile and have something like this:
read PASSWORD
if $PASSWORD != 'pass'; then
echo "wrong. exiting"
exit
fi
Unfortunately, this doesn't work. I get these errors (darwin on 10.6)...
EDIT Sorry about this posting. My browser crashed and I didn't even realize this posted. I ended up figuring it out on my own – again sorry. But thanks for the answers!
You are missing square brackets. The if line should be:
if [ $PASSWORD != 'pass' ]; then
or even better:
if [ "$PASSWORD" != 'pass' ]; then
Which will avoid failure if $PASSWORD is empty.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With