Question : Re:Cygwin Shell Script

Trying to learn how to write a unix shell script. Using cygwin.  When executing the
script, I get an error that reads  

line 11 command not found

If I enter the text that makes the statement true, the script does not error, if the input is
false, I receive an error line 11 command not found.  Below is the code.
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
# Author: 
# Script Name:lscript
# Description:
# Date:
 
echo "What is your name ?"
 
read name
 
 
if $name ='test'
then
echo "Same Name"
else
echo "Different Name"
fi
Open in New Window Select All

Answer : Re:Cygwin Shell Script

Try this:

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
# Author: 
# Script Name:lscript
# Description:
# Date:
echo "What is your name ?"
read name
if [ "$name" = 'test' ]
then
  echo "Same Name"
else
  echo "Different Name"
fi
Open in New Window Select All
Random Solutions  
 
programming4us programming4us