我们可以在对话框中屏蔽特定字段吗?

问题描述 投票:0回答:1

我在 Bash 程序中使用

dialog
来请求用户填写多个字段。我想屏蔽用户输入的密码。

dialog  --title "Server address and login credentials" --form "$msg" 14 60 5 \
"Server Address:   " 1 1 "" 1 20 30 50 \
"Server Port:   " 2 1 "" 2 20 30 50 \
"Gateway Address:" 3 1 "" 3 20 30 50 \
"Logon Name:   " 4 1 "" 4 20 30 50 \
"Logon Password:   " 5 1 "" 5 20 30 50

虽然支持

--passwordbox
,但它会遮盖所有字段。这不是我想要的。在阅读时,我尝试传递
-s -p
选项(
read -p -s password
),但没有成功。我读到我们可以使用
--password-mask
函数,但我不知道如何使用它。

如何防止登录密码被看见?

forms dialog
1个回答
0
投票

我做了一些研究并了解到混合形式选项可用于获得预期的行为。

最后一列中的值控制屏蔽。通过将最后一列值设置为 1 来屏蔽特定字段的值。

dialog --title“服务器地址和登录凭据”--insecure --mixedform“服务器详细信息”14 60 5
“服务器地址:” 1 1 “” 1 20 30 50 0
“服务器端口:” 2 1 “” 2 20 30 50 0
"网关地址:"3 1"" 3 20 30 50 0
“登录名:” 4 1 “” 4 20 30 50 0
"登录密码:" 5 1 "" 5 20 30 50 1 2> /dev/null

参考链接:https://www.unix.com/shell-programming-and-scripting/63682-dialog-menu-script-please-help.html

© www.soinside.com 2019 - 2024. All rights reserved.