Web-based terminal for InterSystems products. Access your database from everywhere!
- Visit the project's page for more details.
- Download the latest version from here.
- Read more and discuss WebTerminal on InterSystems Developer Community.
- Read complete documentation about WebTerminal.
Syntax highlighting & intelligent autocomplete!
Embedded SQL mode!
Even more features!
Native browser application | Allows to access Caché terminal both from desktop and mobile devices. |
Autocompletion | Type faster. Autocomplete is available for class names, variable and global names, methods, properties, etc. |
Tracing | Monitor any changes in globals or files. |
SQL mode | A convenient way to execute SQL queries. |
Syntax highlighting | Intelligently highlighted input both for ObjectScript and SQL. |
Favorites | Save commands you execute frequently. |
Security | All you need is to protect /terminal/ web application, and all sessions are guaranteed to be secure. |
Self-updating | WebTerminal of version 4 and higher prompts to update automatically when new version is available, so you will never miss the important update. |
Explore! | Enjoy using WebTerminal! |
Download the latest version from the project page and import downloaded XML file into any namespace. Compile imported items and the WebTerminal is ready!
After installation, you will be able to access application at http://[host]:[port]/terminal/
(slash at the end is required).
Type /help
there to get more information.
To embed WebTerminal to any other web application, you can use <iframe>
tag. Example:
<iframe id="terminal" src="http://127.0.0.1:57772/terminal/?ns=SAMPLES&clean=1"></iframe>
Note that terminal URL may include optional GET parameters, which are the next:
ns=USER
Namespace to open terminal in. If the logged user has no access to this namespace, the error message will appear and no namespace changes will occur.clean
Start the WebTerminal without any additional information printed. It is not recommended to use this option if you are using terminal as a stand-alone tool (for everyday use), as you can miss important updates.
To use WebTerminal's API, you need to get WebTerminal instance first. Use iframe's
onTerminalInit
function to get it.
document.querySelector("#terminal").contentWindow.onTerminalInit(function (terminal) {
// now work with terminal object here!
});
This function is triggered after WebTerminal establish an authorized connection.
The next table demonstrates available API. Left column are terminal
object properties.
Function | Description |
execute(command, [options], [callback]) |
Executes the ObjectScript command right as if it is entered
to the terminal. However, options provide an
additional flags setup. options.echo (false by default) - prints the command on the screen. options.prompt (false by default) - prompts the user after execution (prints "NAMESPACE > " as well). If callback is passed, the output buffer will come as a first argument of the callback function. |
onOutput([options], callback) |
By default, callback(strings) will be called before the user is
prompted for input, and strings array will always contain an array of
chunks of all the text printed between the prompts. For example, if user writes
write 123 and presses "Enter", the strings will contain
this array: ["\r\n", "123", "\r\n"] . However, when user enters
write 1, 2, 3 , strings will result with
["\r\n", "1", "2", "3", "\r\n"] . You can join this array with
join("") array method to get the full output.Optional options object may include stream property, which
is false by default. When set to true , callback
will be fired every time something is printed to the terminal simultaneously.
|
onUserInput(callback) |
callback(text, mode) is fired right after user presses enter.
Argument text is a String of user input, and
mode is a Number , which can be compared
with one of the terminal mode constants, such as MODE_PROMPT .
|
removeCallback(callback) | Remove any previously assigned callback. Any function which accepts callback returns it, and you can pass the callback here once you no longer need it to stop it from firing. |
print(text) | Prints text which can include special characters and escape sequences. This function is input-safe, and you can print event when terminal is requesting for input without disrupting input. In this case the input will reappear right after text printed. |
Constant | Description |
MODE_PROMPT | Regular input (ObjectScript command) |
MODE_SQL | Input in SQL mode (SQL command) |
MODE_READ | Prompt issued by ObjectScript read c command |
MODE_READ_CHAR | Prompt issued by ObjectScript read *c command |
MODE_SPECIAL | Special CWT's input (commands like /help, /config etc) |
The next example demonstrates a way to intercept terminal's input:
let iFrame = document.querySelector("#terminal");
function myInitHandler (terminal) {
terminal.execute("set hiddenVariable = 7", {
echo: false // the default is false, this is just a demo
});
terminal.onUserInput((text, mode) => {
if (mode !== terminal.MODE_PROMPT)
return;
terminal.print("\r\nYou've just entered the next command: " + text);
});
terminal.onOutput((chunks) => {
// If you "write 12", chunks are ["\r\n", "12", "\r\n"].
// If you "write 1, 2", chunks are ["\r\n", "1", "2", "\r\n"].
if (chunks.slice(1, -1).join("") === "duck") { // if the user enters: write "duck"
alert(`You've found a secret phrase!`);
}
});
}
// At first, handle iFrame load event. Note that the load handler won't work
// if this code is executed at the moment when iFrame is already initialized.
iFrame.addEventListener("load", function () {
iFrame.contentWindow.onTerminalInit(myInitHandler); // handle terminal initialization
});
We are glad to see anyone who want to contribute to Web Terminal development! Check our developer's guide.
To be short, the "hot start" is extremely easy. Having latest Git and NodeJS installed (tested on NodeJS v4-8), execute the following:
git clone https://github.com/intersystems-community/webterminal
cd webterminal # enter repository directory
import # build & import the project. YOU NEED TO EDIT CONSTANTS IN THIS FILE FIRST
Now, in build
folder you will find WebTerminal-v*.xml
file. Every time your
changes are ready to be tested, just run import
again.