Mongo --quiet Not Suppressing - Initial Exit

I am writing this script that takes t and uses it in test.js. I am going to send the issue to my address and my colleagues.

% 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 so that -eval is displayed on the console so that I don't have this dangling “9999” at the top of my results?

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

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

+4
source share
3 answers

A bit of a hack, but until this error is fixed, you can simply switch to tail +2 first, and this will exclude the output that you do not want, for example:

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

This helped me to leave line 9999 as soon as possible.

+2
source

Just in case, someone stumbles over this problem. I had the same problem and got an answer that solves the problem without a shell wrapper:

Use result from mongodb in shell script

+1
source

I understand that some time has passed. Pursuing a decision, hoping this helps someone who has landed on it.

The command prefix with void usually disables the outputs.

For example, try:

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

(NOTE: parentheses are important)

0
source

All Articles