LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help With A Shell Script Error (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-a-shell-script-error-291071/)

PhantomFX 02-16-2005 03:14 PM

Help With A Shell Script Error
 
Can somebody help me with this script please. I'm sorry if it's in the wrong forum but I'm new and couldn't find another relevant forum. I've been trying to write a shell script in a bash shell and when I execute it I get these errors:

./trident: line 13: yes=: command not found
./trident: line 16: yes=: command not found

I tried to fix it myself but just kept getting different errors so can somebody fix it for me please?

echo "Hello. Welcome To The New Text Based Registration System."
echo "Please Enter You First Name"
read fname
echo "Thankyou"
echo "Please Enter Your Surname"
read lname
echo "Thankyou"
echo "Please Enter Your Company Name Or Employer's Company"
read cname
echo "Name: $fname $lname Company/Employer: $cname"
echo "Is This Information Correct"
read yn1
if $yn1= yes
then
echo "Information Stored. Thankyou For Your Time"
elif $yn1= no
then
echo "Please Repeat Process"
until $yn1= yes
do
echo "Please Enter You First Name"
read fname
echo "Thankyou"
echo "Please Enter Your Surname"
read lname
echo "Thankyou"
echo "Please Enter Your Company Name Or Employer's Company"
read cname
echo "Name: fname lname Company/Employer: cname"
echo "Is This Information Correct"
read yn1
done
else
echo "Please Enter 'yes' Or 'no'"
echo "Error Detected Exiting Program"
fi

I'm new at this so it could all be completely wrong but I just want to learn and fix it. I've done some other scripts but when I tried to include a loop its gone wrong thanks in advance to anyone who replys.

david_ross 02-16-2005 03:19 PM

You probably want to use quotes:
Code:

if [ "$yn1" = "yes" ]; then
 echo Yes
else
 echo no
fi


PhantomFX 02-17-2005 04:10 AM

Thanx very much. Finally it works properly. Thanx again for the help.

heema 02-17-2005 04:42 AM

and in the future if have any troubles or questions regarding shell scripts then please post them in the programming forum


All times are GMT -5. The time now is 05:22 AM.