![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Command display output on console and simultaneously save the command and its output | satimis | UNIX for Dummies Questions & Answers | 7 | 01-25-2009 08:27 PM |
| password verification verify password of a user for only first 8 characters | amitpansuria | UNIX for Advanced & Expert Users | 12 | 10-23-2008 11:03 AM |
| console '# ' with {PWD} ?? | gfca | UNIX for Advanced & Expert Users | 2 | 08-14-2008 08:08 PM |
| Change password by pushing encrypted password to systems | benq70 | UNIX for Dummies Questions & Answers | 1 | 09-02-2005 10:08 AM |
| Console Log | kdreaves | UNIX for Dummies Questions & Answers | 4 | 05-21-2004 06:13 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
|||||
|
For bash, the only change needed is to explicitly tell the build-in echo command to interpret "\c" correctly i.e. Code:
passwd=""
omodes=`stty -g`
echo -e "Enter Password: \c"
while :
do
stty raw
c=$(dd bs=1 count=1 2>/dev/null)
stty -raw
# break out of loop if CR found
[[ -z $(echo $c | tr -d "\015") ]] && break
stty echo
echo -e "*\c"
passwd=${passwd}${c}
stty -echo
done
stty $omodes
echo
echo "Password entered: $passwd"
I love the idiosyncrasies of the echo command! |
|
||||
|
if your looking for a simple solution to just hide the password, and you're using bash, you could just use "read -s" ... Code:
#!/bin/bash echo -n "Enter a Password: " read -s pass_value echo "" echo "Password Entered: $pass_value" |
|
|||||
|
My script is here: Reading password and echo * character but it is ksh.
|
![]() |
| Bookmarks |
| Tags |
| shell script, shell scripting, unix scripting, unix scripting basics |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|