There is a program like this:
while true
do
echo 'Your pass: '
read password
if [ $password == 'qwerty' ]; then
echo 'Nice!'
break
fi
done
I can use xargs only if the program has arguments. But in this case ./program.sh password
doesn't work.
I have a list of password and I need to send them in loop to this program.
xargs -a list ./program.sh
doesn't work.
Nice!
if the user entersqwerty
, but also if they enter" qwerty "
(leading or trailing space or tabs with the default value of$IFS
) orq\w\e\r\t\y
... See Understanding "IFS= read -r line", and also if they enter-d / -o y
as your forgot to quote$password
. – Stéphane Chazelas Apr 19 '18 at 10:11stty -echo
before theread
andstty echo
after it, so the password is not displayed in the terminal. – JoL Apr 19 '18 at 17:11