当我试图手动运行下面的脚本时,得到了以下2个错误输出。我不明白的是,它为什么抱怨找不到与')'
匹配的字符?如果我提取then/fi
中的内容并将其放入一个单独的文件中,然后自己运行它,它就可以正常工作,就像它应该发送电子邮件一样。
./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
[email protected]
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
最佳答案
您正在导致问题的第15行使用“此处文档重定向”运算符(<使用以下选项:
daemail=$(cat
echo "From:" $from
echo "To:" $to "Subject:"
echo $subject "You might want to check this... !")
关于linux - 寻找匹配的')'时出现意外的EOF,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37747146/