我有一个脚本,要求用户输入用户名和密码。我想将输入与存储在passwords.txt文件中的用户名和密码变量进行比较。我尝试使用源代码,但它不允许我访问变量。这里是我下面的我的文件部分:从另一个bash脚本验证变量
password.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”语句的语法不正确,这是您正在使用的实际代码吗? – cdarke