I have a simple script I have written for a game. This script is called from ~/.profile in the game user's home directory, and is supposed to simulate a fake login that runs another script upon successfully comparing two variables. It worked for a little while and then abruptly stopped working. (Edit: When I mean it stopped working, I don't mean I changed something and it messed everything up, I mean it stopped working after not touching it for a night.)
#!/bin/bash
pause(){
read -p "Place [CARD] on scanner and press [ENTER] key..."
}
init(){
cat /etc/issue
pause
READ=`sudo ~/bin/Read.py`
CARD=`cat ~/var/keycode.txt`
if [ "$READ" == "$CARD" ]; then
~/bin/mmenu.sh
else
echo "Incorrect... Please try again"
fi
}
while true
do
init
done
What am I doing wrong? Thanks in advance.
Edit: The output of Read.py is 12345, and the output of cat keycode.txt is 12345 yet, it doesn't seem to be able to get them to compare correctly.
The script has been dumbed down, with Read.py not printing, just writing its contents to a file called rcard.txt, and both variables like this:
CARD=`cat ~/var/kcard.txt`
READ=`cat ~/var/rcard.txt`
Try as I might, even with [ "$READ" == "$CARD" ], it still fails the if statement. Even with the contents being the exact same. I really don't get it.