利用颜色实现的口令程序,很简单,初级SHELL,没什么大用,挡一挡操作员也许可以.
功能:输入三次口令失败后,等待5秒钟退出..
最好加在.profile文件中,并将delete键失去作用.
[code:1:57582d4d7e]## passwd_
## 调用文件: lsmenu (背景文件)
xy()
{
_r=$1
_c=$2
_txt=$3
tput cup $_r $_c
echo -n $_txt
}
## 口令检验
password=`date +%y%d%m` #其实就是口令明码,你可以任意修改
count=3
while true
do
clear
sh lsmenu #调用背景文件
xy 6 16 "[30m[47m警告!!!必须经主管授权,请输入口令:\c"
echo "[34m[44m\c"
read passwd
echo [44m
if [ "$passwd" = "$password" ]; then
echo
setcolor -n
break
else
count=`expr $count - 1`
if [ "$count" = "0" ]; then
tput civis
xy 8 16 "[30m[47m你没有机会了...\c[40m"
a=0
b=5
while [ $a -lt 6 ]
do
xy 8 40 [31m$b[37m
tput bel
sleep 1
a=`expr $a + 1`
b=`expr $b - 1`
done
tput cnorm
clear
setcolor -n
exit 1
fi
tput bel
xy 8 16 "[30m[47m口令错!!!还有($count)次机会...[40m\c"
read no
fi
done
##以下可以加上你要调用的程序或命令 ..........
[/code:1:57582d4d7e]
后来为了美观些,又加的背景文件.
[code:1:57582d4d7e]# lsmenu
echo
echo
echo
echo " [44m [40m"
echo " [44m [40m"
echo " [44m [47m [44m [40m"
echo " [44m [47m
[40m [44m [40m"
echo " [44m [47m [40m [44m [40m"
echo " [44m [47m [40m [44m [40m"
echo " [44m [47m [40m [44m [40m"
echo " [44m [40m [44m [40m"
echo " [44m [40m"
echo " [44m [40m"