We have moved to www.dataGenX.net, Keep Learning with us.

Wednesday, January 09, 2013

Hide Password Entry in UNIX script:

We can use 'stty' to hide the password entry in UNIX command prompt, which is like entering password when you login to the UNIX.

'stty' sets options for your terminal

Ex :
  • stty erase \^h --- set the backspace as erase key
  • stty sane
  • stty

Example Script:

echo "Please enter the pwd:"
stty -echo
read pwd
stty echo
if [ "$pwd" == "secret" ]; then
echo "u have access"
  echo "access denied"

till then....
njoy the simplicity.......