Here's part of a shellscript I'm writing checking passwords stored in a file (along with names):
VALID_PASSWORD=`grep "Karl Marks" hiddenpasswords.txt|cut -f2 -d,`
echo $VALID_PASSWORD
echo enter password1
echo "Please enter the password"
read PASSWORD
if test "$PASSWORD" = "$VALID_PASSWORD"
then
echo "you have access"
else
echo "access denied"
fi
The grep part takes the correct password from the file, however "access denied" is always run no matter what I type in.
VALID_PASSWORD. Try sayingecho "${VALID_PASSWORD}."sh -x? Does that tell you what is going wrong? Have you tried echoingecho "[$VALID_PASSWORD]"with the square brackets to indicate the limits of the variable? Have you triedecho "[$PASSWORD]"to see what that yields?read -s PASSWORD(assuming you use bash)