Languages and Scripting
cancel
Showing results for 
Search instead for 
Did you mean: 

Hide the typing password in shell script

sathish12345
Occasional Visitor

Hide the typing password in shell script

Hi,

 

In my shell script, I am connecting to oracle database and executing some queries. For that i am prompting the password to the user. But I want to hide the typing content(password) due to security reason. 

 

In bash , I can pass like "read -s password". But in my servers, bash kernal is not installed. Basic kernal only is there. How to solve this issue??

 

 

Please help me

2 REPLIES
Duncan Edmonstone
Honored Contributor

Re: Hide the typing password in shell script

Surprised google didn't find you this:

 

echo "enter password: \c"

stty -echo

read pw

stty echo

 

And then the passowrd is stored in ${pw}


HTH

Duncan
Highlighted
Steven Schweda
Honored Contributor

Re: Hide the typing password in shell script