SUSE / openSUSEThis Forum is for the discussion of Suse Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Hello All,
I'm running the following script locally and it works as expected but when I ran over ssh (kick of this script from server1 to run on server2), I'm having issue.
Quote:
#!/bin/bash
echo -n "Please enter your ID : "
read ID
ADMUSER=$ID.domain.com
echo -n "Please enter the password for $ADMUSER: "
read PASSWD
so when I kick of the script from server1, it ask me to enter the ID and that works as expected but when it ask me for the password, I enter it, but it displays on the screen.
How can I make it without displaying the password on the screen.
I tried "read -sp" but did not work
Thanks again
Thanks for your reply.
That did not work. Got following..
Please enter your LAN ID): testa
stty: standard input: Invalid argument
Please enter the password for testa.domaim.com: stty: standard input: Invalid argument
drains99
#!/bin/bash
read -p "Please enter your username: " ID
ADMUSER=$ID.domain.com
stty -echo
read -p "Please enter the password for $ADMUSER: " PASSWD
stty echo
echo "debug: $PASSWD"
The code suggested by corp769 works for me, too! I wrote a similar one some time ago: it disables the echo as well and prints an asterisk at each keystroke. You can take a look here.
The code suggested by corp769 works for me, too! I wrote a similar one some time ago: it disables the echo as well and prints an asterisk at each keystroke. You can take a look here.
Maybe he's missing something? I know stty is part of the coreutils package, maybe he don't have certain libs?
+ echo -n 'Please enter a valid remote IP (for replica sync): '
Please enter a valid remote IP: + read remoteip
10.67.132.110
+ for i in '$remoteip'
+ ssh 10.67.132.110 /tmp/edir886/testc.sh
-p Please enter your ID:
i301685
stty: standard input: Invalid argument
-p Please enter the password for testa.domain.com:
drains99
stty: standard input: Invalid argument
debug: drains99
Here is the script thats kicking from server1 to run on server2
Quote:
#!/bin/bash
set -x
echo -n "Please enter a valid remote IP: "
read remoteip
for i in $remoteip
do
ssh ${i} /tmp/edir886/testc.sh
done
Script on server2
Quote:
#!/bin/bash
echo -p "Please enter your ID: "
read ID
ADMUSER=$ID.domain.com
stty -echo
echo -p "Please enter the password for $ADMUSER: "
read PASSWD
stty echo
echo "debug: $PASSWD"
As I said earlier, if I run the script on server2 manually that works.
stty must be connected to a (pseudo)terminal to work properly. You can try to force the pseudo terminal allocation through ssh with the -t option.
Also note that echo has not a -p option. The suggested code had the -p option in the read statement to prompt the user with a question. In other words the following are equivalent:
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.