Sponsored Content
Top Forums Shell Programming and Scripting how to display password as * in the console Post 302270167 by fpmurphy on Friday 19th of December 2008 10:25:28 PM
Old 12-19-2008
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!
 

10 More Discussions You Might Find Interesting

1. HP-UX

reading password and echoing '*' character on console

hi all, I am using HP-UX system. I want echoing * characters while reading password through keyboard instead of blank space. can u help me for that code? Thanks (1 Reply)
Discussion started by: hari_uctech
1 Replies

2. UNIX for Dummies Questions & Answers

Windows to Linux remote console using VNC brings up blank console screen with only mouse pointer

:confused:Hi This was installed on the Linux box a few weeks back by a guy that no longer works for us. All worked fine until last week. Now when we connect its just a blank screen with no icons. I get a whole bunch of errors when starting the service too: Tue Feb 23 14:29:45 2010 ... (1 Reply)
Discussion started by: wbdevilliers
1 Replies

3. UNIX for Advanced & Expert Users

x0vncserver consume 100% resources when view connect to display 0(console)

Hi I would like to ask if someone has suffer and solve the case of vnc server conf running on a solaris system. The x0vncserver consume a 100 percent of resources when the vnc viewer connect to a console display 0. but ok when we connect to a Xvnc server with display :1. (1 Reply)
Discussion started by: jao_madn
1 Replies

4. UNIX for Dummies Questions & Answers

Display Console errors in Red color

I browsed the forums but i couldn't find the best answer.so,i'm posting here again.. I have a parent bash script which calls another child script and the child script is used to deploy the tar file using weblogic deployer. The script is used to display the output on the console and sent to a log... (5 Replies)
Discussion started by: ramse8pc
5 Replies

5. Shell Programming and Scripting

Event logging to file and display to console | tee command is not able to log all info.

My intention is to log the output to a file as well as it should be displayed on the console > I have used tee ( tee -a ${filename} ) command for this purpose. This is working as expected for first few outputs, after some event loggin nothing is gettting logged in to the file but It is displaying... (3 Replies)
Discussion started by: sanoop
3 Replies

6. Solaris

Recover/Reset Sun Java System Server Console password

I am administering a Solaris 10 server that I have root password for but need to get to the system server console. The password has been 'forgotten'. I've tried changing it in /var/opt/mps/serverroot/admin-serv/config/admpw and local.conf with the current hashed password in /etc/shadow for a... (4 Replies)
Discussion started by: jameson
4 Replies

7. Shell Programming and Scripting

Redirect an output from a script to a file and display it at a console simultaneously

Hi, I'd like to redirect the STDOUT output from my script to a file and simultaneously display it at a console. I've tried this command: myscript.sh | tail -f However, it doesn't end after the script finishes running I've also tried this: myscript.sh | tee ~/results.txt But it writes... (3 Replies)
Discussion started by: wenclu
3 Replies

8. SuSE

Display Chinese and Japanese characters on my SLES console.

Hello, I'm trying to figure out how to display Chinese and Japanese Characters on my SLES 11 Console. Is there any way that I could display those characters on my console? Thank you. (3 Replies)
Discussion started by: pjeedu2247
3 Replies

9. Solaris

Sparc console password reset

Hi, How to reset the sun fire v245 console password ?. Please tell me step by step. (5 Replies)
Discussion started by: praveen16
5 Replies

10. SCO

SCO Openserver 6 Console Display Problem

I am trying to upgrade our SCO Openserver 6 box to some newer HW. I can get everything working correctly except for the console display. The boot command shows up correctly, as does the SCO Openserver 6 splash screen. Right as the SCO legal ease is displaying the screen suddenly jumps to only... (4 Replies)
Discussion started by: Jim546
4 Replies
STTY(1) 						      General Commands Manual							   STTY(1)

NAME
stty - set terminal parameters SYNOPSIS
stty [-ag] stty encoded-form stty speed ispeed speed ospeed speed cs5 cs6 cs7 cs8 [-]parenb [-]parodd [-]hupcl [-]cstopb [-]cread [-]clocal [-]ignbrk [-]brkint [-]ign- par [-]parmrk [-]inpck [-]istrip [-]inlcr [-]igncr [-]icrnl [-]ixon [-]ixoff [-]ixany [-]opost [-]onlcr [-]xtabs [-]onoeot [-]isig [-]icanon [-]iexten [-]echo [-]echoe [-]echok [-]echonl [-]noflsh [-]lflusho eof=c eol=c erase=c erase=c intr=c kill=c quit=c susp=c start=c stop=c rprnt=c lnext=c flush=c min=n time=n rows n cols n cooked raw [-]evenp [-]parity [-]oddp [-]nl ek sane DESCRIPTION
Stty shows or changes the parameters of the terminal connected to standard input. Stty takes a myriad of arguments most of which are mapped directly to the flags and special characters described in tty(4), so we won't describe them here. Stty has three forms of operation. First, without any arguments stty shows all terminal attributes that are different from the default state. Option -a makes stty print all terminal attributes, and -g lets stty print the attributes in a special encoded form, a simple row of colon separated hexadecimal numbers. In the second form of operation stty takes an encoded form as produced by the -g option and sets the terminals attributes to its decoded value. In the third form stty interprets a series of flags and parameters settings and modifies the terminal attributes accordingly. Flags can be given as icanon or -icanon for instance, either setting or clearing the ICANON flag. Special character values can by set like intr=^C for example, which sets the interrupt character to CTRL-C. You can either use a real CTRL-C, or the two characters `^' and `C'. In any case it is probably necessary to use quotes to guard it from the shell: intr='^C'. A number alone is interpreted as a baud rate setting for both the input and output rate. The input or the output rate can be set sepa- rately with use of the ispeed and ospeed prefixes to the number. The character size can be set with cs5, cs6, cs7 or cs8. The MIN and TIME value, and the number of rows and columns of the window can also be set using one of the keywords min, time, rows or cols, followed by a decimal number that is the value of the setting. Stty accepts several keywords that are not named by corresponding flags or parameters in tty(4). They set several attributes at once: cooked Same as icrnl ixon opost onlcr isig icanon iexten echo, setting all the attributes that are needed for line oriented mode. raw Same as -icrnl -ixon -opost -onlcr -isig -icanon -iexten -echo, setting all the attributes for a raw data channel. evenp parity These synonyms are equal to cs7 parenb -parodd, setting the line to 7 bits even parity. oddp Same as cs7 parenb parodd, setting the line to 7 bits odd parity. -parity -evenp -oddp All synonyms for cs8 -parenb, setting the line to 8 bits, no parity. nl Same as icrnl, setting carriage return to line feed input translation. -nl Same as -icrnl -inlcr -igncr, disabling any carriage return or line feed handling. ek Set the ERASE and KILL special characters back to the default. sane Set all attributes to the default except things like the line speed and parity, because their "sane" value is probably what it is right now. The default values are compiled into stty from the <termios.h> include file. Use stty sane; stty -a to know what they are. FILES
/etc/ttytab The init field of this file may contain an stty command to set the attributes to match an attached RS232 terminal or modem. SEE ALSO
tty(4), ttytab(5). NOTES
The cooked, raw, rows and cols keywords are Minix additions beyond the keywords defined by POSIX. Rows and cols are common UNIX exten- sions, however. There are more Minix specific flags that match the Minix specific attributes described in tty(4). AUTHOR
Kees J. Bot (kjb@cs.vu.nl) STTY(1)
All times are GMT -4. The time now is 09:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy