urlRewrite.sh: line 17: ((: i<=1: syntax error: operand expected (error token is "1")

安装报错 · resetl · 于 5年前 发布 · 2637 次阅读

在执行脚本的时候出现这样的报错,是什么问题引发的?

共收到 12 条回复 问题提问
Fecmall#15年前 0 个赞

docker安装没有执行下面的部分吧

Fecmall#25年前 0 个赞

Fecmall#35年前 0 个赞

仔细看,就是这个原因导致的,这个问题有类似帖子,可以搜到的

resetl#45年前 0 个赞

我使用的是composer安装,没有用docker安装

Fecmall#55年前 0 个赞

@resetl #4楼 操作系统呢?centos?

resetl#65年前 0 个赞

@Fecshop #5楼 是的 centos

Terry#75年前 0 个赞

把执行这个脚本,完整的log贴上来

https://github.com/fecshop/yii2_fecshop/blob/master/shell/urlRewrite.sh

信息写全,否则不好诊断问题。

Terry#85年前 0 个赞
#!/bin/sh
Cur_Dir=$(cd `dirname $0`; pwd)
# init  full search collection indexes.
$Cur_Dir/../../../../yii  product/search/initindex
# get now update timestamp.
nowtime=`$Cur_Dir/../../../../yii  helper/urlrewrite/nowtime`

# 1.Product 遍历所有产品,把product的url_key 写入到url rewrite
# get product all count.
count=`$Cur_Dir/../../../../yii helper/urlrewrite/productcount`
pagenum=`$Cur_Dir/../../../../yii helper/urlrewrite/productpagenum`


echo "There are $count products to process"
echo "There are $pagenum products pages to process"
echo "##############ALL BEGINING###############";
for (( i=1; i<=$pagenum; i++ ))
do
   $Cur_Dir/../../../../yii helper/urlrewrite/product $i
   echo "Page $i done"
done

你打开这个脚本,$pagenum变量是上面的那个命令行返回的

pagenum=`$Cur_Dir/../../../../yii helper/urlrewrite/productpagenum`

你执行以下 ../../../../yii helper/urlrewrite/productpagenum 看看返回结果, 这样调试以下,就知道问题了。

出现问题,先看源码自己尝试解决。

resetl#95年前 0 个赞
There are 42 products to process
There are 1 products pages to process
##############ALL BEGINING###############
urlRewrite.sh: line 17: ((: i<=1: syntax error: operand expected (error token is "1")
There are 31 categorys to process
There are 1 categorys pages to process
##############ALL BEGINING###############
urlRewrite.sh: line 33: ((: i<=1: syntax error: operand expected (error token is "1")
##############ALL COMPLETE###############
Terry#105年前 0 个赞

我没有遇到这个问题,你百度查查这个报错吧

你是不是改动这个sh代码了、、、

这个问题之前从没有人出过

resetl#115年前 0 个赞

系统文件我不会动的,好的 我查查

Fecmall#125年前 0 个赞

我试了一下,没有问题:

[root@iZ942k2d5ezZ shell]# sh urlRewrite.sh 
There are 43 products to process
There are 1 products pages to process
##############ALL BEGINING###############
Page 1 done
There are 31 categorys to process
There are 1 categorys pages to process
##############ALL BEGINING###############
Page 1 done
##############ALL COMPLETE###############
[root@iZ942k2d5ezZ shell]# 

你按照 #8 的方式,试一下,看看输出, 另外,你用vi -b 的方式打开urlRewrite.sh,看看是否有 ^M,这种特殊的不可见字符等等,你查下资料自己尝试解决试试,我没有这个报错,不好诊断

添加回复 (需要登录)
需要 登录 后方可回复, 如果你还没有账号请点击这里 注册
Your Site Analytics