Introduction to the ObjectScript Shell
InterSystems IRIS® data platform provides a command-line interface (the ObjectScript shell) which is useful during learning, development, and debugging. You can use it to execute ObjectScript commands (and see their results), as well as to access various other shells. It provides an extensive line recall facility as well as several customization options.
The ObjectScript shell is sometimes called the Terminal or the Terminal prompt, which is not entirely accurate because there is also a Windows application named Terminal (which provides a way to access this shell). Where necessary, the documentation uses the more specific phrase Terminal application to refer to the Windows application.
Starting the ObjectScript Shell
You can start the ObjectScript shell in multiple ways:
-
On any operating system, you can use the iris terminal command, starting from an operating system prompt.
-
On Windows, you can use the Terminal application, which is a Windows application that presents the ObjectScript shell in a window that also provides a menu bar with additional options. The Terminal application is described separately in more detail.
You may be prompted to log in, or you may instead be logged in under a default username, depending on the security settings for the associated InterSystems IRIS server. The prompt then (by default) displays the name of the current namespace. For example, if you are in the USER namespace, the default prompt is as follows:
USER>
To switch to a different namespace, use the $namespace variable as in the following example:
USER>set $namespace="SAMPLES"
SAMPLES>
This is the same way that you would switch namespaces within your code; see the $namespace reference page in the ObjectScript Reference for more information.
General Use
You can enter single-line ObjectScript commands at the prompt. No initial space character is needed, unlike lines of code within routines and classes. For example:
do ^myroutine
set dirname = "c:\test"
set obj=##class(Test.MyClass).%New()
write obj.Prop1
The shell implicitly issues the Use 0 command after each line you enter, so that any output is automatically written to the shell.
There is no multiline mode for entering commands, so the entire command must be typed on a single line. (You can, however, define routines within the shell.)
Changes in the Prompt
In specific scenarios, the prompt changes to display additional information, to indicate the program stack level or the transaction level. Also see Shells.
The Program Stack Level (Debug Prompt)
If an error occurs, the prompt includes a suffix that indicates the program stack level. For example:
USER 5d3>
Enter the Quit command to exit the debug prompt. Or debug the error; see Command-line Routine Debugging.
The Transaction Level
If you are within a transaction, the prompt includes a prefix that indicates the transaction level. The prefix is of the form TLn:, where n is the transaction level. For example, if you are in the USER namespace and you enter the ObjectScript command TSTART, the prompt changes as follows:
USER>tstart
TL1:USER>
If you exit the ObjectScript shell, that rolls back the transaction.
Repeating Commands
To repeat a previous command, press the up arrow key repeatedly until the shell displays the desired command. To enter the command, press Enter. The ObjectScript shell also supports a more extensive line recall facility, with an option to search previous commands.
Copying and Pasting
To copy text, select it and press Ctrl+Ins. Then to paste it, press Shift+Ins.
Additional options are available if you are using the Terminal application.
Interrupting Execution
To interrupt any foreground execution, press Ctrl+Shift+c or Ctrl+c.
Scrolling, Pausing, and Resuming
Whenever active text arrives, the ObjectScript shell scrolls to the newly arrived text. Use the scroll bar on the right to scroll up or down.
You can also use the keyboard as follows:
Key Combination | Effect |
---|---|
Ctrl+Home | Scroll to the top of the buffer. |
Ctrl+End | Scroll down to the cursor. |
Ctrl+Page Up | Scroll up by one page. |
Ctrl+Page Dn | Scroll down by one page. |
Ctrl+Line Up | Scroll up by one line. |
Ctrl+Line Dn | Scroll down by one line. |
Ctrl+s | Pause the scrolling. While scrolling is paused, the ObjectScript shell accepts commands and processes them, but it does not write the commands or any output to the screen (and thus appears to be unresponsive). |
Ctrl+q | Resume the scrolling. |
Help Facility
The shell provides a special set of commands. To list them, enter :? at the prompt. Then you will see the following list:
USER>:?
:<number> Recall command # <number>
:? Display help
:py Do $system.Python.Shell()
:mdx Do $system.DeepSee.Shell()
:sql Do $system.SQL.Shell()
:tsql Do $system.SQL.TSQLShell()
:alias Create/display aliases
:clear Clear history buffer
:history Display command history
:unalias Remove aliases
For information on :<number>, :alias, :clear, :history, and :unalias, see Command History and Aliases. For information on :py, :mdx, :sql, and :tsql, see Available Shells.
Exiting
To exit the ObjectScript shell:
-
If you are currently within one of the available (secondary) shells, exit the shell (details vary).
-
Enter HALT or H (not case-sensitive).
If you had accessed the ObjectScript shell from the iris terminal command, the prompt then changes back to the operating system prompt. Or, if you had accessed the Terminal application, the application window then closes.