DEV Community

John Murray for InterSystems

Posted on

3 3

Running OS-level commands from the InterSystems IRIS command prompt

I originally posted this tip a few years ago on InterSystems Developer Community.

When working at the IRIS (or Ensemble or Caché) command prompt I sometimes want to run an operating system command on the server host. By prefixing my command line with ! or $ I can do this with ease. The following examples are from 2020.1 on Windows, but I think the feature is available on all versions and platforms:

USER>!dir

 Volume in drive C is Windows
 Volume Serial Number is XXXX-XXXX

 Directory of c:\intersystems\iris201\mgr\user

11/12/2020  17:31    <DIR>          .
11/12/2020  17:31    <DIR>          ..
23/03/2021  14:00         1,048,576 IRIS.DAT
14/03/2021  10:00                37 iris.lck
11/12/2020  17:30    <DIR>          stream
               2 File(s)      1,048,613 bytes
               3 Dir(s)  134,542,090,240 bytes free
USER>$dir

 Volume in drive C is Windows
 Volume Serial Number is XXXX-XXXX

 Directory of c:\intersystems\iris201\mgr\user

11/12/2020  17:31    <DIR>          .
11/12/2020  17:31    <DIR>          ..
23/03/2021  14:00         1,048,576 IRIS.DAT
14/03/2021  10:00                37 iris.lck
11/12/2020  17:30    <DIR>          stream
               2 File(s)      1,048,613 bytes
               3 Dir(s)  134,542,159,872 bytes free
USER>
Enter fullscreen mode Exit fullscreen mode

If I need to issue more than one command I can almost get myself an interactive shell:

USER>!

c:\intersystems\iris201\mgr\user\> dir
 Volume in drive C is Windows
 Volume Serial Number is XXXX-XXXX

 Directory of c:\intersystems\iris201\mgr\user

11/12/2020  17:31    <DIR>          .
11/12/2020  17:31    <DIR>          ..
23/03/2021  14:00         1,048,576 IRIS.DAT
14/03/2021  10:00                37 iris.lck
11/12/2020  17:30    <DIR>          stream
               2 File(s)      1,048,613 bytes
               3 Dir(s)  134,542,151,680 bytes free
c:\intersystems\iris201\mgr\user\> date
The current date is: 23/03/2021
Enter the new date: (dd-mm-yy)
c:\intersystems\iris201\mgr\user\> exit
USER>
Enter fullscreen mode Exit fullscreen mode

I wrote "almost" because in the example above the date command prompted me to enter a new date but didn't wait for my keystrokes. It behaved as though I had immediately pressed Enter.

Still, I find it a useful feature.

To use it you will need the %System_Callout:USE privilege.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay