请有人能找出我的 shell 脚本中的问题,它在其他 Linux 系统上运行良好,除了 Sunos 下面是我的输出
drifter% cat run.sh
#!/bin/sh -x
if [ ! $JAVA_HOME ] || [ $JAVA_HOME == "" ]
then
echo Enter path to JAVA HOME:
read JAVA_HOME
fi
if [ ! -f $JAVA_HOME/bin/java ]
then
echo "JAVA_HOME variable does not point to a valid java instance"
exit 1
fi
echo "Using JAVA_HOME: "$JAVA_HOME
JAVA_BIN=$JAVA_HOME/bin
ver=`$JAVA_HOME/bin/java -version 2>&1 | head -1 | awk '{print $NF}' | cut -d'.' -f2`
if [ $ver -ge 5 ]
then
JAVA_LIB=`pwd`/lib
export JAVA_LIB
$JAVA_BIN/java -cp ./lib/a-jdbc-sqlserver-4.2.1.jar:./lib/a-jdbc-db2-4.2.1.jar:./lib/ilmInit.jar:./lib/db2jcc.jar:./lib/db2jcc_license_cisuz.jar:./lib/db2jcc_license_cu.jar:./lib/csm-runtime-1.0.jar:./lib/csm-dbutil-1.0.jar:./lib/classes12_g.jar:./lib/commons-beanutils-1.8.3.jar:./lib/commons-cli-1.2.jar:./lib/commons-exec-1.1.jar:./lib/log4j-1.2.8.jar:./lib/groovy-all-1.8.1.jar -Dlog4j.configuration=com/a/csm/log4j.xml -Dendorsed_plugins_dir=./plugins InitValues $@
else
echo Current JDK $ver
echo "Expected JDK 1.5 or later. Please fix your JAVA HOME and try again."
exit 1
fi
drifter% ./run.sh
+ [ ! ]
./run.sh: test: argument expected
drifter%
注意:我正在使用csh
更新
我"$JAVA_HOME"
到处都变了
但我仍然得到
drifter% ./run.sh
+ [ ! /home/ilma1/java16/java ]
+ [ /home/ilma1/java16/java == ]
./run.sh: test: unknown operator ==