最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Mongo --quiet Not Suppressing --eval output - Stack Overflow

programmeradmin0浏览0评论

I'm writing this script that takes in t and uses it in test.js. I'm going to have the output be emailed to me and my collegues.

% mongo my_db --eval 't=9999;' --quiet test.js
9999
------------------------------------------------
Info about stuff going back 9999 days to 2012-08-17.
------------------------------------------------
Stuff x: 433321 (12.43%)
Stuff y: 2723426 (81.57%)
Total: 4524524524

Is there a way to not have what I pass in to --eval be outputted to console so I don't have that dangling '9999' at the top of my results?

Edit: This may be a bug with the --quiet option

See:

I'm writing this script that takes in t and uses it in test.js. I'm going to have the output be emailed to me and my collegues.

% mongo my_db --eval 't=9999;' --quiet test.js
9999
------------------------------------------------
Info about stuff going back 9999 days to 2012-08-17.
------------------------------------------------
Stuff x: 433321 (12.43%)
Stuff y: 2723426 (81.57%)
Total: 4524524524

Is there a way to not have what I pass in to --eval be outputted to console so I don't have that dangling '9999' at the top of my results?

Edit: This may be a bug with the --quiet option

See: https://jira.mongodb/browse/SERVER-4391

Share Improve this question edited Aug 17, 2012 at 14:54 doremi asked Aug 17, 2012 at 14:49 doremidoremi 15.3k31 gold badges97 silver badges152 bronze badges 1
  • 2 +1 Thx for sharing the information that it may be a bug. I hate it when people discover solutions by themselves and don't share them :-). – helpermethod Commented Aug 17, 2012 at 14:57
Add a ment  | 

3 Answers 3

Reset to default 3

Bit of a hack, but until that bug gets fixed you could just pipe to tail +2 first and that would exclude the output you do not want, something like:

% mongo my_db --eval 't=9999;' --quiet test.js | tail +2 

This worked for me in a quick test to leave out the 9999 line.

Just in case anybody stumbles over this issue. I had the same problem and got an answer on that solves the problem without shell magic:

Use result from mongodb in shell script

I realize it has been a while. Posting a solution, hoping it might help someone who landed into this.

Prefixing a mand with a void usually silences outputs.

For example, try:

$ mongo <server>/db script.js --eval 'void (yyyymm="2011-11")'

(NOTE: brackets are important)

发布评论

评论列表(0)

  1. 暂无评论