I am trying to create a very simple login console for a script that I have, this is just for fun to see if it works.
Basically what I thought would be possible is this.
I will read in the file $password_file
and the file $username_file
if there is a certain pattern. Let's say I put in both files "bryan" on the first line (or whatever line). Now I want to put this piece of code before the script continues to its basic functions.
echo "Welcome"
echo "Ur username is:"
read username
echo "Ur password is:"
read password
if sed -n "/$username/" $username_file; then
if sed -n "/$password" $password_file; then
else
exit;
fi
fi
I think I am doing something wrong here, because I am getting an error that there is an unexpected token near the else
.
So basically I just want the if-statement to first read $username_file
, then if the pattern bryan
is in that file, I want it to read the $password_file
, after that I want the script to continue to go to a certain line in the script on which the normal script that I wrote starts.
I hope I explained it right, so that you can understand me.
(I can also expand this little script by adding something like, if username or password is not in that file echo "not found, script will reload try again".)
after that I want the script to continue to go to a certain line in the script on which the normal script that I wrote starts.
Can you please clarify what you want this script to do if the username and password are both found?