Chinaunix首页 | 论坛 | 博客
  • 博客访问: 17621
  • 博文数量: 14
  • 博客积分: 454
  • 博客等级: 下士
  • 技术积分: 145
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-12 15:02
文章分类
文章存档

2011年(14)

我的朋友

分类: 网络与安全

2011-05-12 15:44:04

  1. #!/bin/sh

  2. getchar() {
  3.     stty cbreak -echo
  4.     dd if=/dev/tty bs=1 count=1 2> /dev/null
  5.     stty -cbreak echo
  6. }

  7. printf "Please input your passwd: "

  8. while : ; do
  9.     ret=`getchar`
  10.     if [ x$ret = x ]; then
  11.         echo
  12.         break
  13.     fi
  14.     str="$str$ret"
  15.     printf "*"
  16. done

  17. echo "Your password is: $str"
这样密码显示都是*,想不到shell还能玩到这种地步。
阅读(292) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~