Posted on: 01/09/2022 (last updated: 20/06/2025) • Dj Walker-Morgan •
6minutes
IntelliShell Script Tasks allow scripts to be loaded from disk and run on a schedule with their output saved to disk.
An IntelliShell Script Task is made up of multiple IntelliShell Script units. When the Task is run, each unit will be executed sequentially.
An IntelliShell Script Unit is made up of two components:
A source connection, database: The script will start executing, already connected to the source.
A target file name: A file path and name where the script will write its console output.
The script itself is embedded in the task unit and is edited there.
Creating your first IntelliShell Script Task
Make a New IntelliShell Script Task
Open Tasks (Click the Tasks icon in the toolbar). The Tasks tab will appear:
Click/Select New Task. The New Task window will appear.
Select IntelliShell Script on the New Task window
Select a connection or database to work with in the Intellishell Script dialog that appears:
For this walkthrough, we’ll select the sample_mflix database which is part of the MongoDB Atlas example datasets. Once selected, Click Ok to move on to the script editor:
Write the IntelliShell Script
We can now enter a MongoDB shell script in the editor. Scripts can be a combination of MongoDB queries and JavaScript code. The editor is in the top part of the Script tab:
Enter a query such as:
db.movies.find({"year":1990})
Click the Run script button.
The script will run and the output appears in the Script Output area. The raw shell output will appear in the Raw Shell Output tab. If the output is JSON data, it is shown in its own Shell Output tab as a Table, Tree or JSON.
When your script is run as a Task, its standard output (anything printed to the console/terminal) will be sent to the file selected as the IntelliShell Script Target File. You may edit this to send future output to a different location. For this example, we will leave it as is.
Saving the IntelliShell Script Task
Notice a * in the IntelliShell Script tab. This indicates that there are unsaved changes. Close the IntelliShell Script tab and you will prompted:
Click on Save and a prompt for a name will appear. This is the name for the Task (not for the specific script) and it will appear in the Task Viewer:
Enter “Find 1990” and click OK. You will now return to the Task Viewer with your new script task displayed:
Select the task and click the Run button. The task will run. Its progress will be appear in the Operations Pane:
To view the output, move the cursor over the “IntelliShell Script execution completed” line and right-click for the menu. Then select Reveal in Finder (Mac), Open In Explorer (Windows), or Open in File Explorer (Linux).
You can now navigate to the output file and view the results.
Notes for all IntelliShell Script Task users:
The results from this query will be output as JSON. There will only be 20 records as a prompt of Type "it" for more. That is because this is the precise output of the Mongo shell; it would normally expect user interaction to prompt it to display more. Bear this in mind when creating IntelliShell Script Tasks.
In this example, to output all the matching records, you would use a query which iterated over all the results and printed them out like so:
The .forEach(function(x){ printjson(x); }); tells the script to iterate through all the results, and output them.
Warning
If your collection is large, this can mean that the database will potentially be producing a large amount of output and may have an impact on your database’s performance. When you run a script like this in Studio 3T, all the results will be transferred to the output pane, where it will be paginated for easier reading. In our example, there are around 244 matching documents, so the performance impact is hardly noticeable.
Let’s see how to fix that and in the process, how to edit an IntelliShell Script Task.
Editing your IntelliShell Script Task
Return to the Tasks Viewer:
Select the “Find 1990” IntelliShell Script Task. Then click the Edit button. This will open the overview for the task:
This displays the units available to edit within the IntelliShell Script Task. We only have one unit in this Task as we just created it.
Select the first unit and select Edit Unit. This will display an overview of the three parts of the IntelliShell Script Task – the source, the target, and the script itself:
We want to edit the script itself. The script is editable in this display so click into the editor, and position your cursor at the end of the query. There we can add the print function to the query:
.forEach(function(x){ printjson(x);});
Run the query to test it. Notice the * in the Find 1990 Tab denotes the Task is not saved yet. Click Save Task to save the entire task and update it.
Close the IntelliShell Script #1 tab and return to the IntelliShell Script Overview Tab.
Click Run to run the modified Task. View the results using the Operations pane to locate them. You should have a JSON document with all the matching documents now.
You have now completed editing your IntelliShell Script Task.
Script Units
An IntelliShell Script Task is contains multiple IntelliShell Script units. Each unit encapsulates a source database or connection, a target file, and a script. The IntelliShell Script – Overview Tab is where you can add new Script units, and edit or remove existing units. When the Task runs, Studio 3T will execute each script unit sequentially in the order shown in the overview.
If you want to make IntelliShell Script Tasks from existing scripts, save each script to disk, then create a new Task. In the editor for that task, use the Open button to load your saved script into that unit.
Output Targets
The IntelliShell Script Target File controls which file an IntelliShell Script Task Unit will write its output into.
Edit the field that is directly above the editor and to the right of the IntelliShell Script Source setting. Clicking on the folder icon allows you to select the output file using a GUI file dialog.
The file path and name support filename placeholders. When a task runs, the placeholders in the file name expand to the current date-time, date, or time. This allows you to create Tasks which, when scheduled and run, create output files which do not overwrite existing output files. Learn more about filename placeholders in this introductory article.
Scheduling
Like all other tasks, IntelliShell Script Tasks can be run on a schedule. There are multiple ways to edit the Tasks’ schedule. While editing a Task, you can use the Schedule button in the Task Overview. Or, if you are in the Tasks view, you can select the task and click the Tasks’ view Schedule button. Both options lead to the same Schedule dialog.
Dj has been around since Commodore had Pets and Apples grew everywhere. With a background in Unix and development, he's been around the technology business writing code or writing content ever since.
We value your privacy
With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data.
By clicking “Accept all”, you consent to the storage of cookies and the processing of personal data for these purposes, including any transfers to third countries. By clicking on “Decline all”, you do not give your consent and we will only store cookies that are necessary for our website. You can customize the cookies we store on your device or change your selection at any time - thus also revoking your consent with effect for the future - under “Manage Cookies”, or “Cookie Settings” at the bottom of the page. You can find further information in our Privacy Policy.
With your consent, we and third-party providers use cookies and similar technologies on our website to analyse your use of our site for market research or advertising purposes ("analytics and marketing") and to provide you with additional functions (“functional”). This may result in the creation of pseudonymous usage profiles and the transfer of personal data to third countries, including the USA, which may have no adequate level of protection for the processing of personal data. Please choose for which purposes you wish to give us your consent and store your preferences by clicking on “Accept selected”. You can find further information in our Privacy Policy.
Accept all cookies
Manage consent preferences
Essential cookies are strictly necessary to provide an online service such as our website or a service on our website which you have requested. The website or service will not work without them.
Performance cookies allow us to collect information such as number of visits and sources of traffic. This information is used in aggregate form to help us understand how our websites are being used, allowing us to improve both our website’s performance and your experience.
Functional cookies collect information about your preferences and choices and make using the website a lot easier and more relevant. Without these cookies, some of the site functionality may not work as intended.
Social media cookies are cookies used to share user behaviour information with a third-party social media platform. They may consequently effect how social media sites present you with information in the future.