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
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.

验证:

[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 ~]#
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.