0

我有以下代码

#!/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”附近的语法错误

4

1 回答 1

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”放在脚本的第二行,看看会发生什么

于 2013-04-04T13:12:22.910 回答