Reputation: 973
I need the js variable to be passed through command line arguments. The option --eval did this. But it also printing the variable value to the shell by default. I want to skip the variable value printed to the shell.
Ex:-
I have used "user_name" inside the script.js
Passing the value using mongo --eval="user_name='john'" script.js
But it un necessarily printing the value
john
Any ideas.
Upvotes: 0
Views: 919
Reputation: 5143
For this use case you could use var
in your declaration. This will not print the value:
mongo --eval="var user_name='john';" script.js
Upvotes: 1
Reputation: 18111
There is a --quiet
flag - but evaluated items are still printed to stdout.
You could pipe to /dev/null or a file to capture the stdout eg:
mongo --eval="user_name='john'" script.js > /dev/null
Upvotes: 1