Home » Infrastructure » Linux » Invisible parametr passing in Linux  () 1 Vote
Invisible parametr passing in Linux [message #258979] Tue, 14 August 2007 00:35 Go to next message
shilpa.rajput
Messages: 31
Registered: May 2006
Location: Pune
Member

Hello All,
I've written a shell script for database helthchecking.
To make it to be used for various databases running, I made it interactive. The prompts are database name, user name & password.
Now the problem is, while entering the password, it'll be visible while entering as a parameter.
I want nothing to appear while entering the password. Is there any way in Linux to make this happen?
Thanks in advance.
Re: Invisible parametr passing in Linux [message #258998 is a reply to message #258979] Tue, 14 August 2007 01:36 Go to previous messageGo to next message
Michel Cadot
Messages: 68718
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Use something like:
echo "Enter password: "
stty -echo
read pwd
stty echo

Regards
Michel

[Updated on: Tue, 14 August 2007 01:37]

Report message to a moderator

Re: Invisible parametr passing in Linux [message #259001 is a reply to message #258998] Tue, 14 August 2007 01:41 Go to previous messageGo to next message
shilpa.rajput
Messages: 31
Registered: May 2006
Location: Pune
Member

Great..
Thanks a lot, Sir.. It worked Smile

[Updated on: Tue, 14 August 2007 02:25]

Report message to a moderator

Re: Invisible parametr passing in Linux [message #261565 is a reply to message #258979] Thu, 23 August 2007 01:14 Go to previous message
shilpa.rajput
Messages: 31
Registered: May 2006
Location: Pune
Member

Dear All,
just to let u know,got another solution for the same :

 read -s -p "Enter Password: " pwd 

this will create the variable $pwd which will be invisible.


Regards,
Shilpa
Previous Topic: How to trim variable
Next Topic: script not executing in cron
Goto Forum:
  


Current Time: Thu Dec 05 15:29:33 CST 2024