脚本的需求如windows输入密码一样
1、输入正确就直接进去
2、输入失败显示密码错误,请再次输入
我写了半天没写出来~~求高人!!!!
1、输入正确就直接进去
2、输入失败显示密码错误,请再次输入
我写了半天没写出来~~求高人!!!!
0
- #! /bin/bash
- ## Writen by Aming!
- ## Judging for a word if is your password.
- pass="nihao123"
- while :; do
- read -p "Please input the password:" word
- if [ $word != $pass ]; then
- echo "The password is wrong, retry."
- else
- exit
- fi
- done
0
[root@bogon sbin]# sh password.sh
Please input the password:adf
The password is wrong, retry.
Please input the password:adf
The password is wrong, retry.
Please input the password:adf
The password is wrong, retry.
Please input the password:adfg
The password is wrong, retry.
Please input the password:adfasdf
The password is wrong, retry.
Please input the password:adfgadfa
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:sdew
The password is wrong, retry.
Please input the password:234
The password is wrong, retry.
Please input the password:34454
The password is wrong, retry.
#! /bin/bash
## Writen by Aming!
## Judging for a word if is your password.
pass="nihao123"
while :; do
read -p "Please input the password:" word
if [ $word != $pass ]; then
echo "The password is wrong, retry."
else
exit
fi
done
没有问题呀。只要你输不对是不会退出的。
Please input the password:adf
The password is wrong, retry.
Please input the password:adf
The password is wrong, retry.
Please input the password:adf
The password is wrong, retry.
Please input the password:adfg
The password is wrong, retry.
Please input the password:adfasdf
The password is wrong, retry.
Please input the password:adfgadfa
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:adfadf
The password is wrong, retry.
Please input the password:sdew
The password is wrong, retry.
Please input the password:234
The password is wrong, retry.
Please input the password:34454
The password is wrong, retry.
#! /bin/bash
## Writen by Aming!
## Judging for a word if is your password.
pass="nihao123"
while :; do
read -p "Please input the password:" word
if [ $word != $pass ]; then
echo "The password is wrong, retry."
else
exit
fi
done
没有问题呀。只要你输不对是不会退出的。
编辑回复