![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| awk Shell Script error : "Syntax Error : `Split' unexpected | Herry | UNIX for Dummies Questions & Answers | 2 | 03-17-2008 08:16 AM |
| "syntax error at line 21 :'done' unexpected." error message" | ibroxy | Shell Programming and Scripting | 3 | 08-08-2007 03:45 AM |
| syntax error at line 59: `end of file' unexpected | Remi | SUN Solaris | 4 | 01-16-2007 11:48 AM |
| for loop not working - syntax error at line 6: `end of file' unexpected | debojyoty | Shell Programming and Scripting | 2 | 03-10-2006 12:45 PM |
| sh: syntax error at line 1: `>' unexpected | atiato | High Level Programming | 2 | 03-16-2004 04:39 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
syntax error at line 33: `elif` unexpected
Code:
#!/bin/sh
echo "Choose option: e, d, l, t, p, or x."
read option
if test $option = e
then
echo "Filename?"
read file
if test ! -f $file
then
echo "No such file"
else
echo "Yes its a file"
fi
elif test $option = d
echo "Directory?"
read dir
if test ! -d $dir
then
echo "no such dir"
else
echo "yes its a dir"
fi
elif test $option = l
then
ls
elif test $option = t
then
date
elif test $option = p
then
echo "Make file readable to all"
read filep
if test $filep ! -f $file
then
echo "no file exists"
else
chmod 777 $file
fi
elif test $option = x
then
echo "bye"
"menuscript" 74 lines, 647 characters
syntax error at line 33: `elif` unexpected Any ideas? |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Where do you begin; there are so many things wrong.
Code:
if [ $option == e ] then ... do something ... elif [ $option == d ] then ... do something ... else ... do something else .. fi |
|
#3
|
|||
|
|||
|
Should there be a fi at the end of the last elif statement?
elif test $option = x then echo "bye" fi |
|
#4
|
|||
|
|||
|
Yes, and there should be a "then" after "elif test $option = d".
Since the OP is trying to lear the constructs, it's much better to start small and add more. |
|
#5
|
|||
|
|||
|
i was missing then after the elif statement.
thanks for that. i read over it so many times and didnt see it |
|||
| Google The UNIX and Linux Forums |