With the old mongo shell, you could set up a shell file (called something like mongo_cmd.sh)containing the path to the executable and all the command line switches you wanted like this:
```
/path/to/mongo --norc --quiet --port 26011
```
and then in your other script files pipe commands into an invocation of mongo_cmd.sh like the following:
```
CMD_FILE=./mongo_cmd.sh
STATS=$(echo 'db.stats().ok' | $CMD_FILE)
DBVERSION=$(echo 'db.version()' | $CMD_FILE)
echo "db.stats().ok output:" $STATS
echo "db.version() output:" $DBVERSION
```
and the output would be this:
```
db.stats().ok output: 1
db.version() output: 6.0.5
```
But if you replace mongo with the new shell mongosh in the above, the output becomes garbles with the mongosh shell prompt appearing both before and after each command output:
```
db.stats().ok output: Enterprise s1 [direct: primary] test> 1 Enterprise s1 [direct: primary] test>
db.version() output: Enterprise s1 [direct: primary] test> 6.0.5 Enterprise s1 [direct: primary] test>
```
The new mongosh shell should either be fixed to replicate the old shell behaviour, or it should be enhanced with a new command line switch --legacy that can be used to revert the behaviour for that session.