2013-03-11 45 views
0

我什麼都試過,即使去除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" 

可能是什麼原因 我如何處理這個

回答

2

我想你的代碼,它爲我工作得很好。您正在使用哪個版本的Expect
順便說一句,我通常這樣寫:

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