I am trying to run this command from bash script:
mongo 192.168.10.20:27000 --eval \"use admin && db.shutdownServer() && quit()\"
From the mongo docs:
--eval option
Use the --eval option to mongo to pass the shell a JavaScript fragment, as in the following:
mongo test --eval "printjson(db.getCollectionNames())"
You can also put your JS Fragments into a .js
file then do:
mongo < myScript.js
You may also find more useful stuff in this SO question