Reputation: 1159
I have written this script as a module in installing postgres and this is to show the user that the database has been created and get his/her input as to they see the database was created. When I run the script, I get the error
./dbtest: line 39: [: missing `]'
I have tried adding " " around yes and '' around yes and I can't figure out what is missing. The script is as follows
#
#
# Check to make sure the database was created and who is the owner
#
#
if [ -f showdb ];
then
cp showdb /home
else
echo " show database file is missing "
fi
if [ -f /home/showdb ];
then
su - postgres -c '/home/showdb'
echo " Do you see the data name created listed above? "
echo " "
echo " Type yes or no (type out the whole word please) "
echo " "
read dbawr
if [ $dbawr == yes && $dbawr == Yes ];
then
echo "Great!"
exit
else
echo " Please contact tech support "
pause " Press [CTRL] [Z] to exit the program now "
fi
else
echo " File Missing!!"
fi
What am I missing in this script?
Thanks!
Upvotes: 2
Views: 7606
Reputation: 28059
You can't use the boolean &&
operator withing the single brackets conditional [ test = test ]
. If you're using bash (or a similar shell), the preferred syntax is to use the double brackets:
[[ this == this && that == that ]]
If you're worried about portability, then you should stick with the single brackets, but use them like so:
[ this = this ] && [ that = that ]
Note that I didn't use the double equals (==
). That's not posix compliant either.
Upvotes: 6