For some reason, the mongo shell does not output the result of the command when a Javascript file is executed:
$ echo "db.stats()" >db-stats.js
$ mongo -u user -p pass db db-stats.js
MongoDB shell version: 3.0.3
connecting to: db
$
There's no output or any indication of how it went, as far as I can see.
Is there a way to improve this?
For example, when I run mongo shell semi-interactively, then I see the result:
$ echo "db.stats()" | mongo -u user -p pass db
MongoDB shell version: 3.0.3
connecting to: db
{
"ok" : 0,
"errmsg" : "not authorized on db to execute command { dbstats: 1.0, scale: undefined }",
"code" : 13
}
bye