【1.1】shell基本实践——密码输入三次错误则结束

 

function checkPwd()
{
        pwdCount=1
        read -s -p "Please input the password: " thePwd
        clear
        while true; do
                if [ "${pwdCount}" -ge 3 ]; then
                        echo "bye"
                        exit 1
                fi
                if [ "$thePwd" = "123456" ]; then
                        break
                else 
                        echo "Error: The password is error."
                        echo 
                        read -s -p "Please input the password: " thePwd
                        clear
                fi
                pwdCount=`expr ${pwdCount} + 1`
        done
}

 

posted @ 2020-01-08 18:25  郭大侠1  阅读(570)  评论(0编辑  收藏  举报