Maciej Cygan Maciej Cygan - 5 months ago 22
Linux Question

unexpected EOF while looking for matching `)'

I am getting the following 2 error outputs when i try to run manually my script below. What i do not understand is why does it complain that it can not find matching character for

')'
? where as if i extract whats inside the
then/fi
and put this into a single file and run it it on its own it works just fine as in it sends email as it should.

./rsnapshot-log-checker: line 15: unexpected EOF while looking for matching `)'
./rsnapshot-log-checker: line 25: syntax error: unexpected end of file

grep "ERROR" /var/log/rsnapshot.log | \
while read line ; do
echo "$line" | grep "ERROR"
if [ $? = 0 ]
then
to=warning@bla.com
subject="Error rsnapshot - `hostname`"
from=`hostname`@bla.com
daemail=$(cat <<! <-- line 15
From: $from
To: $to Subject:
$subject You might want to check this... !) <-- maching haracter for )

echo "$daemail" | /usr/sbin/sendmail -t
fi
done
<-- line 25

Answer

You are using Here document redirection operator(<<) on line 15 that is causing issue. Use following:

daemail=$(cat
         echo "From:" $from
         echo  "To:" $to "Subject:"
         echo  $subject "You might want to check this... !")
Comments