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/")
As an add on:
If you also want to get back the result of your command you may use CPIPE device.
See my article and the related example in OEX and this fresh one for Python
Great resource Cemper! Thanks for sharing