Results 1 to 8 of 8
I want to hide the entered key from keyboard like when i enter password it shows me *, so how can i do this by programming.I am taking username and ...
- 06-01-2007 #1Just Joined!
- Join Date
- Jun 2007
- Posts
- 3
hiding keyboard input
I want to hide the entered key from keyboard like when i enter password it shows me *, so how can i do this by programming.I am taking username and password from user and i want to hide password by printing * when entering password.
Help!!!!
- 06-01-2007 #2
- 06-01-2007 #3Just Joined!
- Join Date
- Oct 2006
- Posts
- 47
use Xlib Programming
- 06-01-2007 #4
Well that does not solve any problem does it? First of all if you are going to use Xlib you need X Window System and also you need to be programming in C (or in a language that can use C-libs).
He could use Ncurses if he wanted or he could write the whole thing by himself but we can't just tell him what to use unless we know what programming language he is using or if he wants a graphical application.
- 06-01-2007 #5Just Joined!
- Join Date
- Jun 2007
- Posts
- 3
- 06-01-2007 #6Just Joined!
- Join Date
- Jun 2007
- Posts
- 3
hiding .....
I Am Using Shell Scripting... I Just Want * On Pressing Any Key From Keyboard..just Give Me Linux Command I Will Integrate That Command In My Script
- 06-01-2007 #7
Okay, I wrote a little script to get you started:
You will need to replace the <ENTER KEYCODE> with the correct "character" that represents a keypress of the [Enter] key. This is usually ^M, but I'm not sure if that always works.Code:#!/bin/sh stty_orig=`stty -g` stty -icanon -icrnl -echo min 0 time 0 key="" password="" while [ "$key" != <ENTER KEYCODE> ] do key="" while [ "$key" = "" ] do read key done if [ "$key" != <ENTER KEYCODE> ] then echo -n "*" password=$password$key fi done stty $stty_orig
This is just to get you started, it gets much more complicated when you need such functions as you should be able to erase characters.
- 06-02-2007 #8
nal's script is correct, but do you need it to print *s? Most Linux apps just print nothing at all, and if you're okay with that, the script becomes FAR FAR simpler. The easiest way would be to do:
The only complex thing here is the use of 'stty', which allows you to control the terminal. Here, we turn off the printing of characters entirely, enter the password, and then re-enable it. This way, you do not need to manually print characters or read them one-by-one or anything like that. It just works.Code:#!/bin/bash stty_orig=$(stty -g) echo -n "Enter Your Password: " stty -echo read password stty $stty_orig echo "Your password is: $password"
DISTRO=Arch
Registered Linux User #388732


Reply With Quote
