Shell输入密码时关闭屏幕回显
Shell输入密码时关闭屏幕回显
Shell输入密码时关闭屏幕回显
在实际应用中,一般当我们在键盘上键入口令时不希望将其显示在屏幕上,
为此可采用下面的两种办法:
·使用stty 命令
stty -echo # do not display password
echo “Enter password: \c”
read PASSWD #get the password
stty echo # restore standard configuration
·使用echo命令
设置保密属性:echo “\033[8m”
取消保密属性:echo “\033[m”
评论暂时关闭