I wrote this sh script here. What it suppose to be doing is it prompts the user to type in the old password, then checks the password with the password in the "PASSWORD.txt" file if not it would exit, else if it matches then it would ask the user to type in the new password twice. Then it checks if the two new passwords are the same if not it would exit, else i should put the input the user typed and replace the text in the "PASSWORD.txt" file.
Then when i ran the file where it askes me for the old password i got this error:
Please Enter teh old passsword:
test
cat: .txt: No such file or directory
The password doesn't match![root@guzzy ~]#
The thing is the input i typed doesn't match even though i typed the correct old password.
Here is the scirpt below:
#!/bin/sh
clear
echo -e "Please Enter the old password:"
read old
if [ "$old" != "$(cat $PASSWORD.txt)" ]
then
echo -n "The password doesn't match!"
exit
else
echo -n "The old password matches!"
echo -n "Please Enter New password:"
read new1
echo -n "Please Enter New password again:"
read new2
if [ "$new1" != "$new2" ]
then
echo -n "The new passwords don't match!"
exit
else
$new1 >> PASSWORD.txt
echo -n "The new password has been saved!"
fi
fi
Please help thanks!