Password program in unix
Hi,
I wanna write password program in unix Code:
stty -echo |
You can use read -s instead of stty. If you want those *, though, you will probably have to implement that yourself. Something like (pure bash) could work:
Code:
pass='' Maybe the more advanced languages (Perl etc.) have a function for that, though. |
Thanks for the response,
I am new to shellscript and not able to grab the syntax, can you pls tell me what is doing What I understood : We are reading the input character by character and in case statement checking the characters. I am not able to catch the case statement. Backspace is also taken as input, I want to make the backspace and DELETE keys to behave normal way. |
OK, so first, I used read with some arguments:
-s for silent input -r to disable interpreting of backslashes -N 1 to read one character each time The case statement is quite simple: The first case handles backslashes: it removes one * from the prompt. pass="${pass%?}" removes the last character from the string The second case terminates the loop when you press ENTER The last case is for all other characters: the character read is appended to $pass variable The backspace should work as expected (it does for me), but it may depend on your terminal settings. As for DELETE, you would have to add special case for that. But that would also imply handling the arrow keys and the work with the string would get much more complex. And I don' think it would be very useful since you can't see what you type anyway. |
You may also want to read these
http://rute.2038bug.com/index.html.gz http://tldp.org/LDP/Bash-Beginners-G...tml/index.html http://www.tldp.org/LDP/abs/html/ |
Is there any password program in shell script which handles all possibilties such as left arrow, right arrow, delete, backspace etc
I want my password program to read only characters, spcial characters and numbers like a standard password program. |
Quote:
Try looking at the man page for the script command, it may do what you want. |
All times are GMT -5. The time now is 07:13 AM. |