Article
YURI MARX GOMES · Jan 20 1m read

Running shell commands in ObjectScript

Sometimes it is necessary to execute commands from the shell of the host operating system, where your ObjectScript program is located, to launch programs, operating system services, schedule crontasks, among other activities. For this, the language has a utility procedure called $ZF(-100). See:

$ZF(-100,flags,program,args)

Where flags is the type of command you want to execute. In our case, the flag is "/ SHELL", to execute shell commands on the host operating system.

Program is the name of the program or service to be executed.

Args are execution arguments passed to the program.

An example would be to print some content at the prompt, for example:

$ZF(-100,"/SHELL","echo","https://www.intersystems.com/")

If your program depends on changing the current directory, to run the program, use the following command before the call:

Do ##class(%SYSTEM.Process).CurrentDirectory("/path/")
30
1 2 2 280
Log in or sign up to continue

Great resource Cemper! Thanks for sharing