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
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:
I realize it has been a while. Posting a solution, hoping it might help someone who landed into this.
Prefixing a command with a void usually silences outputs.
For example, try:
$ mongo <server>/db script.js --eval 'void (yyyymm="2011-11")'
(NOTE: brackets are important)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.