Welcome To suyashjain.blogspot.com

For Latest and more contents visit http://www.i3w.in

Tuesday, August 19, 2008

Password input from command line in shell script

Some time you are writing a shell script which asks for some secret
answer which you don't want to display on screen. To avoid echoing the
input entered by users , do this.

setty -echo
read secretanswer
setty echo

First line will disable the echo
Second line will take the input , but will not display whatever user typed
Third line again enable the echo

No comments: