Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

user input needs hashing 1

Status
Not open for further replies.

tjbradford

Technical User
Dec 14, 2007
229
GB
Script
----------
echo Please enter your username:
read Username
Echo Please Enter you password:
read Password

vpnclient connect $username $password &
----------------------------------------

I want to hash the password when its being entered is this now going to require another 200 lines of code to obtain what i'm after?

 
And if read -s doesn't work

[tt]
echo "Password: \c"
stty -echo
read passwd
stty echo
echo
[/tt]


HTH,

p5wizard
 
And here's a code snippet I googled (comp.unix.shell on unix.derkeiler.com) and modified a bit.

It reads one character at a time and echos the typed character out as hash signs. But granted, it is not smart enough (yet) to handle backspace erasing...

[tt]#!/bin/ksh
echo "please enter password: \c "
ch='';
pass='';

stty -echo
stty raw

cr=$(echo "\r\c")

while [ "$ch" != "${cr}" ]
do
pass=${pass}${ch}
ch=$(dd bs=1 count=1 2> /dev/null)
echo "#\c"
done
stty -raw
stty echo

echo
echo "The password you entered is ${pass}"
[/tt]


HTH,

p5wizard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top