搜索建议index的脚本运行时的syntax错误

bug问题 · ganbugandong · 于 5年前 发布 · 1506 次阅读
There are 37 products to process
There are 1 pages to process
##############ALL BEGINING###############
fullSearchSync.sh: 17: fullSearchSync.sh: Syntax error: Bad for loop variable

普通的lamp服务器,第一次在这上面run搜索的索引,不确定是什么原因,我看循环的变量时$pageNum. 发现这个sh脚本问题还挺多的,不是很generic

第17行:

for (( i=1; i<=$pagenum; i++ ))

谢谢

FYI:

pagenum=`$Cur_Dir/../../../../../yii product/search/syncpagenum`
共收到 3 条回复
Fecmall#15年前 1 个赞

从 ubuntu 6.10 开始,ubuntu 就将先前默认的bash shell 更换成了dash shell;其表现为 /bin/sh 链接倒了/bin/dash而不是传统的/bin/bash

allen@allen-lql ~/workspace/script $ ls -l /bin/sh
lrwxrwxrwx 1 root root 4 Aug 12 14:29 /bin/sh -> dash

解决办法一:

将默认shell更改为bash。(bash支持C语言格式的for循环)

sudo dpkg-reconfigure dash
在选择项中选No

解决方法二:

修改代码: https://github.com/fecshop/yii2_fecshop/blob/master/shell/search/fullSearchSync.sh#L17

改为:

for i in `seq $pagenum`

管用了,谢谢!

Fecmall#35年前 0 个赞

@ganbugandong #2楼 嗯,linux各个发行版的不同(小差异),用centos就不会出这个问题。

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