Irritating Shell script problem - " unmatched

Hi,

I have the below KSH shell script:

#!/usr/bin/ksh
 
if [ $1 = "" ]; then
    echo "Usage: resourceSts <server>
else
  if [ $1 = "abc1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
 
   elif [ $1 = "abc2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "def1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "def2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "ghi1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "ghi2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
 
   elif [ $1 = "jkl1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "jkl2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "mno1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "mno2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "pqr1" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
   elif [ $1 = "pqr2" ]; then source="<server>"
      ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF
  fi  
fi

but when I execute it I get the error:

./resourceSts: syntax error at line 65: `"' unmatched

I'm pretty certain it's just a typo, but for life of me I can't find it. Anyone have any ideas?

Line 4:

echo "Usage: resourceSts <server>"
     ssh <userid>@$source > output 2>/dev/null <<_EOF
      scstat -g
      _EOF

The here-document will not work because the terminating _EOF is not in column 1. All your script from the first <<_EOF is being treated as part of the first here-document. Thus only the first few lines have been syntax checked.

All those "elif" statements are hard to follow (if they work). Have you considered using "case".

About the _EOF issue, you can just replace all instances of

... <<_EOF

by

... << -_EOF

That way, the marker need not to be on a beginning of line.

With this syntax, the marker must be preceded by a tabulation !

Jean-Pierre.

Indeed, more precisely one or more tabulations and no spaces or other characters.