码迷,mamicode.com
首页 > 系统相关 > 详细

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

时间:2020-01-08 18:37:08      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:code   word   echo   exit   inpu   col   错误   div   shel   

 

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
}

 

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

标签:code   word   echo   exit   inpu   col   错误   div   shel   

原文地址:https://www.cnblogs.com/gered/p/12168146.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!