./monitor: syntax error at line 86: `end of file' unexpected

./monitor: syntax error at line 86: `end of file' unexpected

Post by Micha Grunber » Fri, 03 Oct 2003 16:28:43



Hi,

Everytime I run this script I get the following error.
PLEASE HELP


#!/bin/sh

## Variabales
PATH=${PATH}:/apps/verisity/sn_rel4.1/license/solaris
# The LIST variabale has to be set to the file that contains a list of hosts
LIST=list
ALIVE=0
DEAD=0
LOGFILE=/home/sysadmin/logs/log.`date +%y%m%d`
export LIST ALIVE DEAD LOGFILE PATH
if [ -f ${LOGFILE} ] ; then
        mv ${LOGFILE} ${LOGFILE}.old

echo "\n UNIX SYSTEM REPORT for `date`" >> $LOGFILE
for i in `cat $LIST`
do
        HOST=`ping $i | awk '{print $1}'`
        if [ $i = $HOST ]
        then
                ALIVE=`expr ${ALIVE} + 1`
                echo "\n This is the status report for $HOST" >> $LOGFILE
                echo "\n ------------------------------------------------"

Quote:>> $LOGFILE

                echo "\n\n" >> $LOGFILE

                echo "\n This yp server for $HOST is `/bin/rsh $HOST
"/bin/ypwhich"`" >> $LOGFILE
                echo "\n" >> $LOGFILE

                echo "\n These are the local filesystems that are mounted on
$HOST" >> $LOGFILE
                echo "\n" >> $LOGFILE
                /bin/rsh $HOST "/bin/df -lk" >> $LOGFILE
                echo "\n" >> $LOGFILE

                echo "\n These are the filesystems that are shared from
$HOST" >> $LOGFILE
                echo "\n" >> $LOGFILE
                /bin/rsh $HOST "/usr/sbin/dfshares" >> $LOGFILE
                echo "\n" >> $LOGFILE

                case $HOST in
                        "lotus")
                                echo "\n LICENSES" >> $LOGFILE






                                LICUP=`cat /tmp/lic | grep UP | wc -l`
                                cat /tmp/lic >> $LOGFILE
                                if [ $LICUP -eq 14 ]
                                then
                                        echo "\n All the LICENSES on $HOST
are up" >> $LOGFILE
                                else
                                        echo "\n Not all the LICENSES on
$HOST are ok" >> $LOGFILE
                                fi
                                \rm /tmp/lic;;
                        "jasmine")
                                echo "\n LICENSES" >> $LOGFILE

                                LICUP=`cat /tmp/lic | grep UP | wc -l`
                                cat /tmp/lic >> $LOGFILE
                                if [ $LICUP -eq 2 ]
                                then
                                        echo "\n All the LICENSES on $HOST
are up" >> $LOGFILE
                                else
                                        echo "\n Not all the LICENSES on
$HOST are ok" >> $LOGFILE
                                fi
                                \rm /tmp/lic;;
                        "geranium")
                                echo "\n LICENSES" >> $LOGFILE

                                LICUP=`cat /tmp/lic | grep UP | wc -l`
                                cat /tmp/lic >> $LOGFILE
                                if [ $LICUP -eq 4 ]
                                then
                                        echo "\n All the LICENSES on $HOST
are up" >> $LOGFILE
                                else
                                        echo "\n Not all the LICENSES on
$HOST are ok" >> $LOGFILE
                                fi
                                \rm /tmp/lic;;
                esac
        else
                DEAD=`expr ${DEAD} + 1`
        fi
done

 
 
 

./monitor: syntax error at line 86: `end of file' unexpected

Post by Andreas Kahar » Fri, 03 Oct 2003 16:59:03



> Hi,

> Everytime I run this script I get the following error.

You mean the error in the subject?

[cut]

Quote:> export LIST ALIVE DEAD LOGFILE PATH
> if [ -f ${LOGFILE} ] ; then
>         mv ${LOGFILE} ${LOGFILE}.old

Where's the "fi" for that "if"?

--
Andreas K?h?ri

 
 
 

./monitor: syntax error at line 86: `end of file' unexpected

Post by Ed Morto » Fri, 03 Oct 2003 21:52:17



> Hi,

> Everytime I run this script I get the following error.
> PLEASE HELP


> #!/bin/sh

> ## Variabales
> PATH=${PATH}:/apps/verisity/sn_rel4.1/license/solaris
> # The LIST variabale has to be set to the file that contains a list of hosts
> LIST=list
> ALIVE=0
> DEAD=0
> LOGFILE=/home/sysadmin/logs/log.`date +%y%m%d`
> export LIST ALIVE DEAD LOGFILE PATH
> if [ -f ${LOGFILE} ] ; then
>         mv ${LOGFILE} ${LOGFILE}.old

<snip>

Missing "fi". The following small awk script would catch that if you ran
it on this file:

awk '
     $1 == "if" { ifs++; print NR ": " $0 }
     $1 == "fi" { ifs--; print NR ": " $0 }
     $1 == "case" { cases++; print NR ": " $0 }
     $1 == "esac" { cases--; print NR ": " $0 }
     $1 == "for" { loops++; print NR ": " $0 }
     $1 == "while" { loops++; print NR ": " $0 }
     $1 == "until" { loops++; print NR ": " $0 }
     $1 == "done" { loops--; print NR ": " $0 }
     END {
         if ( ifs != 0 ) { print ifs " unbalanced if ... else(s)" }
         if ( cases != 0 ) { print cases " unbalanced case ... esac(s)" }
         if ( loops != 0 ) { print loops " unbalanced [for|while|until]
...  done (s)" }
     }
' $1

When ran on your script it produces:

11: if [ -f ${LOGFILE} ] ; then
16: for i in `cat $LIST`
19:         if [ $i = $HOST ]
39:                 case $HOST in
50:                                 if [ $LICUP -eq 14 ]
55:                                 fi
62:                                 if [ $LICUP -eq 2 ]
67:                                 fi
74:                                 if [ $LICUP -eq 4 ]
79:                                 fi
81:                 esac
84:         fi
85: done
1 unbalanced if ... else(s)

Regards,

        Ed.

 
 
 

1. syntax error at line 18: `end of file' unexpected


Most likely, one of your conditionals or loops is not closed.  That is,
there's an 'if' without a closing 'fi,' a 'case' without a closing
'esac,' or a 'do' without a 'done.'  The shell is searching for whatever
it's missing until it gets to the end of the file, then it issues the
error.
--
UUCP:           {rutgers|ames|uunet}!mimsy!wb3ffv!fallst!tkevans

Tim Evans       2201 Brookhaven Ct, Fallston, MD 21047

2. LILO version 22.7.1 released

3. Q: "sh: syntax error at line 1: `end of file' unexpected"

4. unix date and time

5. line 130: syntax error: unexpected end of file

6. 2.1.5R Installation problem

7. syntax error: unexpected end of file

8. Problem with mounting using eth0 addr

9. ./mozilla-bin: syntax error at line 1: `(' unexpected

10. syntax error at line 1: `(' unexpected

11. syntax error at line 27 : `do' unexpected

12. make: Fatal error in reader: lib.make, line 26: Unexpected end of line seen

13. make: Fatal error in reader: .make.stake, line 1233: unexpected end of line seen