proc getpassword {{prompt "Password: "}} { puts -nonewline $prompt flush stdout # disable echoing exec stty -echo catch { gets stdin } password options exec stty echo return -options $options $password }Gotcha! On some versions of Solaris (at least) you need to pass the descriptor that you want to modify on stdin to the subprocess. On Linux, you don't need to: it defaults to the terminal that is the controlling TTY. Because of this difference, you are recommended to invoke stty like this:
exec stty {*}$whateverArguments <@stdin
# Alternatively... exec stty {*}$whateverArguments </dev/tty
The Expect extension includes an stty command that takes much the same sort of parameters as the unix utility command.