意外令牌'else'错误附近的语法错误

时间:2014-07-09 16:04:07

标签: shell

#!/usr/bin/bash
. ~/.profile
exec &> /export/home/oracle/scripts/Test_OHS_status.log
/opt/app/oracle/Middleware/Oracle_WT1/instances/instance1/bin/opmnctl status
chmod 777 /export/home/oracle/scripts/Test_OHS_status.log
if [ -f /export/home/oracle/scripts/Test_OHS_status.log ] ; then
cp /export/home/oracle/scripts/Test_OHS_status.log /home/sedward
chmod 777 /home/sedward/Test_OHS_status.log
grep "[Alive, Down]" /home/sedward/Test_OHS_status.log | mailx -s "Test - OHS Status" steven10@gmail.com < /home/sedward/Test_OHS_status.log
fi
else
echo "something wrong with Test OHS" | cat >> /home/sedward/Test_OHS_status.log | mailx -s "check if oracle HTTP server is up on Test" steven10@gmail.com < /home/sedward/Test_OHS_status.log

1 个答案:

答案 0 :(得分:0)

如错误消息所述,您有语法错误。

关闭if块,然后尝试使用else块:

...
fi
else
...

else需要成为if块的一部分:

if ... then
...
else
...
fi