2012-11-27 17 views
0

我有一個程序在MinTTY(cygwin的shell)下運行,並調用GetConsoleMode/SetConsoleMode失敗。 _getch回聲到控制檯。這是一個原生的win32應用程序,沒有綁定到cygwin環境,所以任何cygwin函數都沒有了。如何關閉回顯以便我可以輸入密碼?如何在MinTTY下打開回聲?

回答

0

我基本上是仿效以下通過popen

save_state=$(stty -g) 

/bin/echo -n "Account: " 
read acct 
/bin/echo -n "Password: " 
stty -echo 
read password # this won't echo 
stty "$save_state" 

echo "" 
echo account = $acct and password = $password 
Read more at http://www.askdavetaylor.com/how_to_read_password_without_echoing_c.html#Z3FtcTtMHe0gJdES.99 
相關問題