收到错误通过的bash运行蒙戈shell命令
问题描述:
我工作在Solaris 10上,与2.0.4
mongo
版本,收到错误通过的bash运行蒙戈shell命令
{root} #: ./mongo --shell --eval 'use db'
MongoDB shell version: 2.0.4
fork() available!
connecting to: test
type "help" for help
Tue Sep 20 14:44:22 compile error: (shell eval):1 SyntaxError: Unexpected identifier
use db
^^
{root} #:
我写了一个脚本,我试图插入一组文件在DB:
#!/bin/bash
cd /test2/sam
for f in *.bin.gz do
cd /opt/csw/bin
./mongofiles -l /test2/sam/$f -d mahi put $f SUBSTRING=$(echo $f| cut -c11-19) ./mongo << EOF
use mahi "db.fs.files.update({\ $filename: \"$f" },{ \$set: {"ROP": \"$SUBSTRING"}})"
EOF
done
mahi是db名称;在执行这个时,我得到的编译错误为:
Tue Sep 20 15:05:40 compile error: (shell):1 SyntaxError: Unexpected token } _ROOT_MO_R,MeContext=CTL01008_celltracefile_3-1378091167645.bin.gz" },{ $set:
任何导致帮助我解决这个问题,表示赞赏。
答
删除--shell
从文档
--shell. Used in conjunction with a JavaScript file (i.e. ) to continue in the mongoshell after running the JavaScript
此外, --eval是仅对于JScript不是蒙戈外壳命令。在cmd行指定db。
我写了一个脚本,我试图插入一个集DB#文件!/斌/庆典 CD/TEST2/SAM 对于f以* .bin.gz 做 CD /选择/ CSW/bin ./mongofiles -l/test2/sam/$ f -d mahi put $ f SUBSTRING = $(echo $ f | cut -c11-19) ./mongo
您应该使用[edit]按钮并确保显示脚本的正确测试。我不得不从评论中猜测。 –