lock 终端
时间:2006-05-17 来源:huanghaojie
#!/bin/sh
#lockit
#trap signals 2 3 and 15
trap "nice_try" 2 3 15
#get the device we are running on
TTY=`tty`
nice_try()
{
#nice_try
echo "Nice try,the terminal stays locked"
}
# save stty settings hid characters typed in for the password
SAVEDTTY=`stty -g`
stty -echo ####隐藏键盘的输入
echo -n "enter your password to lock $TTY :"
read PASSWD
clear
while :
do
#read from tty only !!,
read RES < $TTY #####读取当前终端键盘的输入
if [ "$RES" = "$PASSWD" ]; then
#password unlocking
echo "unlocking..."
break
fi
#show wrong password or hits return
echo "wrong passwd and terminal is locked.."
done
#restore stty settings
stty $SAVEDTTY ##解除隐藏键盘的输入
#lockit
#trap signals 2 3 and 15
trap "nice_try" 2 3 15
#get the device we are running on
TTY=`tty`
nice_try()
{
#nice_try
echo "Nice try,the terminal stays locked"
}
# save stty settings hid characters typed in for the password
SAVEDTTY=`stty -g`
stty -echo ####隐藏键盘的输入
echo -n "enter your password to lock $TTY :"
read PASSWD
clear
while :
do
#read from tty only !!,
read RES < $TTY #####读取当前终端键盘的输入
if [ "$RES" = "$PASSWD" ]; then
#password unlocking
echo "unlocking..."
break
fi
#show wrong password or hits return
echo "wrong passwd and terminal is locked.."
done
#restore stty settings
stty $SAVEDTTY ##解除隐藏键盘的输入
相关阅读 更多 +