为什么即使在我执行stty -echo之后,密码仍然可以在瞬间显示?

问题描述:

我什么都试过,即使去除stty的回声线,但用户键入他的password.i正在考虑它的一些超时问题,所以我想withh所有类型的超时值与徒劳的尝试后,第二密码是一个瞬间可见为什么即使在我执行stty -echo之后,密码仍然可以在瞬间显示?

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)"