文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>lock 终端

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   ##解除隐藏键盘的输入
相关阅读 更多 +
排行榜 更多 +
无敌赛车王

无敌赛车王

赛车竞速 下载
多人汽车聚会

多人汽车聚会

赛车竞速 下载
漂移基地

漂移基地

赛车竞速 下载