[英]Error running --eval mongodb command
I tried to run javascript (js) file to get shard's config server information, it runs fine in mongo shell but as result is too large to analyse on command prompt, i tried to save the output in a file using below mentioned command 我试图运行javascript(js)文件以获取碎片的配置服务器信息,它在mongo shell中运行良好,但是由于结果太大,无法在命令提示符下进行分析,因此我尝试使用以下提到的命令将输出保存到文件中
F:\git\bits-n-pieces\scripts> mongo --shell wts.js aggutil.js \
--eval "printjson(wts('config192'))" > out.log
MongoDB shell version: 2.6.4 connecting to: test
type "help" for help
2015-02-16T15:48:34.088+0530
ReferenceError: wts is not defined
As i am trying to load as well run js function concurrently, it is not running, Could anyone provide a approach to run the function of js and save the output to file. 当我试图同时加载以及运行js函数时,它没有运行,任何人都可以提供一种方法来运行js函数并将输出保存到文件中。
You don't want --shell
with the redirection >
as this will redirect the shell to stdout and the program will appear to hang. 您不希望
--shell
使用redirection >
因为这会将Shell重定向到stdout,并且程序似乎挂起。
mongo test.js test1.js --eval "var t = 900" > out.txt
Plus, it looks like something is wrong with your javascript files since it's complaining that wts
isn't defined. 另外,您的JavaScript文件似乎有问题,因为它抱怨
wts
。 Did you paste in exactly what you see when you run that command? 您是否完全粘贴了运行该命令时看到的内容? If I use a command like yours
如果我使用像你这样的命令
mongo --shell test.js test1.js --eval "var t = 900" > out.txt
I get no output at all because of the stdout redirect. 由于stdout重定向,我根本没有任何输出。 If I take out the
>
, I get 如果我取出
>
,我得到
MongoDB shell version: 2.6.6
connecting to: test
type "help" for help
loading file: test.js
loading file: test1.js
>
What version of the shell are you running? 您正在运行什么版本的Shell?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.