Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1065911
  • 博文数量: 186
  • 博客积分: 4939
  • 博客等级: 上校
  • 技术积分: 2075
  • 用 户 组: 普通用户
  • 注册时间: 2010-04-08 17:15
文章分类

全部博文(186)

文章存档

2018年(1)

2017年(3)

2016年(11)

2015年(42)

2014年(21)

2013年(9)

2012年(18)

2011年(46)

2010年(35)

分类: Python/Ruby

2011-04-28 18:44:50

  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还能玩到这种地步。
阅读(1540) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~