shell中的if比较

virusswb 2017-09-25 02:49:02
autoTaskFinish.sh查询数据库,有返回值
if [ "$rtn" -ge 1 ]; then
echo "0"
exit 0
else
echo "1"
exit 100
fi

下面的这个shell调用上面的shell
#!/bin/bash
vday=$1


while true;
do
vexists=`sh /home/oracle/shell/new/autoTaskFinish.sh $1`
echo $vexists
if [ $vexists -eq 0 ]; then
echo "autotask is finished."
fi
# if [[ "$vexists" -eq 0 ]]; then
# echo "autotask is finished."
# break
# else
# echo "autotask is not finished. continue....."
# echo "sleep 5s"
# sleep 2s
# fi
done


运行的时候报错了,[: too many arguments
我修改为
if [[ $vexists -eq 0 ]]
还是报错syntax error in expression (error token is ":

改成
if [[ "$vexists" -eq 0 ]]
还是报错syntax error in expression (error token is ":

我修改为if [[ "$vexists" == "0" ]]; then
不会报错了,但是始终是不会进入这个if条件,不管之前的shell返回的是0还是1,也就是判断失效了,哪位帮忙解释一下!!!
...全文
312 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
mymtom 2017-10-09
  • 打赏
  • 举报
回复
运行了,没有设么问题呀!

23,121

社区成员

发帖
与我相关
我的任务
社区描述
Linux/Unix社区 应用程序开发区
社区管理员
  • 应用程序开发区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧