开发者

Unexpected end of file in BASH

Writing a simple bash script to do some checks for me in the morning: One part is pulling down some html files and making sure that they exist. The other part is ensuring some local files are present, and emailing if they are not. The problem I am facing is that I am receiving a "syntax error: unexpected end of file" and I can't really understand why it i occuring. Here is a simplified version of the code:

for myHost in $HOSTS
do
  result=$(wget -T $TIMEOUT -t 1 $myHost -O /dev/null -o /dev/stdout)
  result2=$(echo $result | grep "awaiting response")
  connected=$(echo $result | grep "404");
  if [ "$connected" != "" ]; then
    for myEMAIL in $EMAIL
    do
      echo -e "$(date) - $myHost is down! \n This is an automated message." | mailx -r "box.email.com"  -s "$SUBJECT开发者_如何学JAVA" $myEMAIL
    done
  fi
done

numoffiles=`find . -maxdepth 1 -mtime -1 | grep -i .html | wc -l`
if [ "$numoffiles" -ne 5 ]; then
  FILE=$(find . -maxdepth 1 -mtime -1 -print| grep -i .html)
  mailx -r "box.email.com"  -s "FILE MISSIN" "$EMAIL" << EOF
  EOF
fi

from using sh -x I can see that it gets to assigning the number of reports to the var "numoffiles", but then it just believes that is the end of the file. has anyone got any suggestions?


There should not be any space before the end of heredoc label:

   EOF
^^^

Change it to

EOF
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜