| 1 | #!/bin/bash |
| 2 | # secret-pw.sh: secret password |
| 3 | |
| 4 | echo |
| 5 | echo -n "Enter password " |
| 6 | read passwd |
| 7 | echo "password is $passwd" |
| 8 | echo -n "If someone had been looking over your shoulder, " |
| 9 | echo "your password would have been compromised." |
| 10 | |
| 11 | echo && echo # Two line-feeds in an "and list." |
| 12 | |
| 13 | |
| 14 | stty -echo # Turns off screen echo. |
| 15 | # May also be done with |
| 16 | # read -sp passwd |
| 17 | # A big Thank You to Leigh James for pointing this out. |
| 18 | |
| 19 | echo -n "Enter password again " |
| 20 | read passwd |
| 21 | echo |
| 22 | echo "password is $passwd" |
| 23 | echo |
| 24 | |
| 25 | stty echo # Restores screen echo. |
| 26 | |
| 27 | exit 0 |
| 28 | |
| 29 | # Do an 'info stty' for more on this useful-but-tricky command. |