Your Ad Here
首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 操作系统 > Linux > lock 终端
【标  题】:lock 终端
【关键字】:lock
【来  源】:http://www.cublog.cn/u/7869/showart.php?id=113869

lock 终端

Your Ad Here #!/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   ##解除隐藏键盘的输入

[精品推荐]shell命令[转帖]:【上一篇】
理解Linux内核(2)----内存管理和设备驱动简介:【下一篇】
【相关文章】
  • 让WinXP开机时Numlock键自动打开
  • clock命令
  • Stale lock installed for pkgadd ,
  • 15.12 The lock statementreleases the lock.
  • IClassFactory::LockServer
  • 15.2 Blocks
  • Can I block IM by FortiGate firewalls
  • 对lock的认识
  • 本周技术关注[面向webapps运维]: Mysql Host '...' is blocked 错误 - Metro的
  • sp_lock2 返回附加的锁定细节
  • 【随机文章】
  • EMC存储设备与powerpath的关系
  • 去除字符串前后空格
  • /proc/sys目录下的部分参数的优化调整
  • C++Builder中不规则窗体的快速显示
  • 使用boost::thread::condition实现并发程序
  • 在Rational Application Developer中开发简单Portlet(一)
  • 配置一款漂亮的Win XP系统
  • struts 的路径问题
  • 20051024配置服务器连接池及连接类
  • Visual Basic对象使用
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 bbb软讯网络 All Rigths Reserved.