I want to try out executing javascript from mongo shell. mongo test --eval "printjson(db.getCollectionNames())"
However, I'm getting the error as you can see on the above screenshot.
The "--eval" option is used in Scripted mongo, you should not be already connected to the shell. Use that as in an example below:
mongo YOUR_DB_NAME --eval "printjson(db.getCollectionNames())"