Bash脚本:';语法错误:";“金融机构”;意外';嵌套语句内

Bash脚本:';语法错误:";“金融机构”;意外';嵌套语句内,bash,shell,syntax,scripting,syntax-error,Bash,Shell,Syntax,Scripting,Syntax Error,我正在尝试编写一个脚本来切换HAproxy,以便在服务关闭时将用户重新路由到维护页面。以下是我遇到的问题: if [ "$idIsValid" = "false" ]; then if [ "$(cat isUp)" = "true" ]; then echo "Site is down! Routing to maintenance page." echo false > isUp mv haproxy.cf

我正在尝试编写一个脚本来切换HAproxy,以便在服务关闭时将用户重新路由到维护页面。以下是我遇到的问题:

if [ "$idIsValid" = "false" ]; then
    if [ "$(cat isUp)" = "true" ]; then
            echo "Site is down! Routing to maintenance page."
            echo false > isUp
            mv haproxy.cfg haproxy.cfg.temp
            mv haproxy.cfg.other haproxy.cfg
            mv haproxy.cfg.temp haproxy.cfg.other

            #restart haproxy
            service haproxy restart
            echo "Restarting HAproxy"

    elif [ "$(cat isUp)" = "false" ]; then
            #do nothing since it has already changed
            echo "Nothing to do; service is still down."
    else
            #notify me that isUp is set to something other than true or false, or something else is wrong.
    fi
fi
当我运行此操作时,我会得到以下错误:

status-check.sh: Syntax error: "fi" unexpected

此错误指向倒数第二行的嵌套fi。我在这里很难找到语法错误。请协助!谢谢。

这是因为最后一个
else
块中没有命令。如果删除此块或在其中放入命令(不是注释),则不会出现语法错误。

会告诉您原因。@BenjaminW。谢谢你的链接!从现在起,我将使用它。它总是一些愚蠢的东西…非常感谢你的帮助!