意外标记'else'错误附近的语法错误
问题描述:
#!/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" [email protected] < /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" [email protected] < /home/sedward/Test_OHS_status.log
答
正如错误消息所述,您有语法错误。
您关闭if
块,然后尝试使用else
块:
...
fi
else
...
的else
需要在if
块的一部分:
if ... then
...
else
...
fi
+0
非常感谢大卫!我的问题已解决。 – user3826612
的StackOverflow不进行调试。这就是聊天的目的! –
http://tldp.org/HOWTO/Bash-Prog-Intro-HOWTO-6.html – Michelle