Bash password prompt
#!/bin/bash # cf. Creating password prompts using Bash, http://ubuntuforums.org/showthread.php?t=269592 # For yet another example of how to use keys in shell scripts see: # arrows - example how to use cursor keys in ksh scripts, # http://www.shelldorado.com/scripts/quickies/arrows.txt stty_orig=$(stty -g) # Init some stuff... pass='' blank='false' # Main loop executed once for each char typed... while [[ "$blank" != "true" ]]; do stty -icanon -echo c=$(dd bs=6 count=1 2> /dev/null) # Check for a CR. if [ -z "$(printf -- "$c" | tr -d "\r\n")" ]; then blank='true' else stty echo echo -n "*" pass="$pass$c" stty -echo fi done stty icanon echo echo printf -- "$pass\n" stty "$stty_orig" exit 0