I am doing a simple shell script, such that it should read data from the user through stdin and shouldn't display the letters, instead it should display * for each letter.
It is just like the password prompt...
For example: The output should be like this
Quote
Enter the password: *****
I have Coded the program, but it is not terminating....
Here is the code
#! /bin/sh
echo -n " Enter the password: "
while [ 1 ]
do
read -s -n1 key
echo -n "*"
if [ "$key" == "\n" ]
then
echo -n "@@@"
break
fi
done
exit 0
The Program is working as I expected, but the while loop is going infinite.I can understand that, the problem is in
if [ "$key" == "\n" ]Can anyone tell me how to solve this issue...


Sign In
Create Account


Back to top









