#!/bin/bash
ReadPassword(){
#turn off terminal echo to prevent peeping!
echo -n ">>> "$1
stty_orig=`stty -g`
stty -echo
read tempstr
stty $stty_orig
eval "$2=$tempstr"
echo "******"
}
ReadString(){
echo -n ">>> "$1
read tempstr
eval "$2=$tempstr"
}
ReadPassword "Please input your password:" MYPASSWD
echo $MYPASSWD
[ZT]读取密码的shell实例
最新推荐文章于 2024-05-14 06:00:00 发布
本文介绍了一种使用Bash脚本实现的安全密码输入方法,通过禁用终端回显来防止密码泄露,同时提供了字符串输入的功能。这种方法适用于需要在命令行环境中安全获取用户密码的应用场景。
952

被折叠的 条评论
为什么被折叠?



