- Reference >
- Legacy
mongo
Shell > - Native Methods in the Legacy Shell >
- isInteractive()
isInteractive()¶
On this page
Note
The native method listed here is for the legacy mongo
shell.
To use native methods in mongosh
, see
Native Methods in mongosh.
-
isInteractive
()¶ New in version 4.2.
Returns a boolean value indicating if the current
mongosh
session is running in interactive mode or in script mode:true
if in interactive modefalse
if in script mode
Examples¶
Interactive Mode¶
Issuing Operations inside the Shell¶
Connect mongosh
to a deployment. Inside
mongosh
, run:
The method returns true
.
Running a Javascript File inside mongosh
¶
Create a JavaScript testExample.js
file with the content:
Connect mongosh
to a deployment. Inside
mongosh
, load the javascript file (see
load()
):
The method returns the following in mongosh
:
Script Mode¶
Create a JavaScript testExample.js
file with the content:
From a terminal/command-line prompt (i.e. not inside
mongosh
), specify the javascript file to
mongosh
in order to execute the file, as follows:
The operation prints to the terminal information about the MongoDB shell version and various information followed by: