意外标记‘fi’附近有语法错误

意外标记‘fi’附近有语法错误

当我尝试执行以下 shell 命令时,出现以下异常

bash: ./qa_domain_pdp_auto_startup_script.sh: line 11: syntax error near unexpected token fi
bash: ./qa_domain_pdp_auto_startup_script.sh: line 11: fi;

下面是 sh 文件。

#!/bin/bash
echo "starting execution"
domain_pdp_process_id=`/bin/ps -fu "pdpadmin"|grep "/home/pdpadmin/app/payara41/glassfish/domains/pdp/"|grep -v "grep" | awk '{print $2}'`
echo "getting process id"
zeroProcessId=0
if [ "$domain_pdp_process_id" -gt "$zeroProcessId" ];
then
    echo "domain pdp is running"
else
    echo "domain pdp is not running"
fi;
exit;

请指教

答案1

不确定是否存在问题(在手机上),但您有多余的代码;,所以我将代码重组为:

if [ "$domain_pdp_process_id" -gt "$zeroProcessId" ]; then
    echo "domain pdp is running"
else
    echo "domain pdp is not running"
fi

或者:

if [ "$domain_pdp_process_id" -gt "$zeroProcessId" ]
then
    echo "domain pdp is running"
else
    echo "domain pdp is not running"
fi

相关内容