意外标记'fi'附近的语法错误

时间:2013-04-04 13:01:04

标签: linux bash shell unix

我有以下代码

#!/bin/bash
export PATH=/usr/bin:/usr/local/bin
ssh -o PasswordAuthentication=no -q pspew@8.76.82.179 exit
test=$?
echo "return value  is $test"
if [ $test -eq 127 ] ; then
    echo "welcome"
fi

当我执行脚本时,我得到$ test并获得一些错误行

意外令牌`fi'

附近的语法错误

1 个答案:

答案 0 :(得分:2)

代码

#!/bin/bash
export PATH=/usr/bin:/usr/local/bin
ssh -o PasswordAuthentication=no -q pspew@8.76.82.179 exit
test=$?
echo "return value  is $test"
if [ $test -eq 127 ] ; then
echo "welcome"
fi

没有语法错误 你可以将“set -vx”放在脚本的第二行,看看会发生什么

相关问题