首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

Shell运用编程之开机密码欢迎welcome

2012-11-26 
Shell应用编程之开机密码欢迎welcomeShell应用编程之开机密码欢迎welcome描述:若用户希望锁定对终端的访问

Shell应用编程之开机密码欢迎welcome

Shell应用编程之开机密码欢迎welcome

描述:若用户希望锁定对终端的访问,但不想退出并再次登录,则可以编写一个脚本程序实现。

当调用该脚本时,知道用户输入正确的密码才能退出。

其中:ctrl + u  删除整行

            ctrl + b 删除前一个字符

           粗体显示字符

shell程源序:

trap " " 2 3 4stty -echo#tput belstty kill \^ustty erase \^btput bold#tput blinktput bel#tput dimif [ $# -gt 0 ]then   MESG="$@"else  MESG="This system is locked"fitput cleartput cup 5 10; echo "Enter your passwd>\c"read pword_1tput cleartput cup 10 20;echo "$MESG"pword_2=until [ "$pword_1" = "$pword_2" ]do  tput rev  read pword_2donestty echotput clearexit 0

分析:通过trap捕捉信号,设置中断信号、退出信号均已屏蔽,即ctrl + c,del ,Break键均不管用。

热点排行