0
点赞
收藏
分享

微信扫一扫

linux shell实现测试用户名与密码是否正确


judge_user_passwd.sh

#!/bin/bash

read -p "Please input username:" user
read -p "Please input password:" pass
if [ "$user" == 'ztj' -a "$pass" == '123456' ];then
echo "Login Successful"
else
echo "Login Failed"
fi

验证:

[root@logstash ~]# sh judge_user_passwd.sh 
Please input username:a
Please input password:b
Login Failed
[root@logstash ~]# sh judge_user_passwd.sh 
Please input username:ztj
Please input password:123456
Login Successful
[root@logstash ~]#

举报

相关推荐

0 条评论