DEV Community

John Murray for InterSystems

Posted on

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.

Top comments (0)