Passwords 为什么即使在我做stty-echo之后,密码也会在一瞬间可见?

Passwords 为什么即使在我做stty-echo之后,密码也会在一瞬间可见?,passwords,expect,password-protection,Passwords,Expect,Password Protection,我尝试了一切,甚至删除了stty回显线路,但在用户键入密码后,密码会在一瞬间可见。我认为这是超时问题,所以我尝试使用各种超时值,但都是徒劳的尝试 set timeout 30 stty -echo send_user -- "Password for $username :" expect_user -re "(.*)\n" set timeout .000000001 set timeout 30 send_user "\n" set timeout 30 set password $expe

我尝试了一切,甚至删除了stty回显线路,但在用户键入密码后,密码会在一瞬间可见。我认为这是超时问题,所以我尝试使用各种超时值,但都是徒劳的尝试

set timeout 30
stty -echo
send_user -- "Password for $username :"
expect_user -re "(.*)\n"
set timeout .000000001
set timeout 30
send_user "\n"
set timeout 30
set password $expect_out(1,string)
send -- "$password\r"
原因可能是什么
我如何处理这个

我试过你的代码,它对我来说很好。您使用的是哪个版本的
Expect

顺便说一下,我通常这样写:

stty -echo
send_user "Password: "
expect_user -timeout 3600 -re "(.*)\n"
stty echo
send_user "\r\n"
set passwd "$expect_out(1,string)"