I have a script that asks for the user to enter a username and password. I want to compare the input to the username and password variables stored in a passwords.txt file. I tried using source but it does not give me access to the variables. Here are my parts of my files below:
passwords.txt
#!/bin/bash
username="username"
password="password"
script.bash
#!/bin/bash
echo "Enter username"
read -r user
echo "Enter password"
read -r pass
source passwords.txt
if("$user" == "$username" && "$pass" == "$password") then
echo "You have successfully logged in"
else
echo "You entered the wrong credentials"
fi
If you can, please help me figure out how to compare the two variables in different files.
ifstatement is incorrect, is this the actual code you are using?