意思是我需要写用户名和密码,脚本告诉我我是谁
发布于 2018-12-18 19:05:58
我希望您不想编写一个真正的登录脚本,而是想玩一下脚本。下面的脚本将按照您的要求执行…的操作
#!/usr/bin/env bash
read -p "username: " username
read -p "password: " password
case $username in
admin|user|anonymous)
if [[ $password == $username ]]; then
echo "you are $username"
else
echo "wrong password"
fi
;;
*)
echo "username not available"
esac…但它也有一些缺陷:
脚本提示输入用户名和密码,并将它们存储在变量$username和$password中。然后检查$username是admin、user还是anonymous之一。如果是,它将检查$username和$password是否匹配。
https://unix.stackexchange.com/questions/489741
复制相似问题