Execute sudo commands from InterSystems Lite Terminal
IRIS is installed and running in an Ubuntu VM.
Visual Studio Code is being used in the host Windows OS and is connected to the IRIS server.
When attempting to execute commands with sudo from the InterSystems Lite Terminal in VSCode using $ZF(-100), error code 127 is returned.
I tried configuring Ubuntu to avoid password prompts by adding the following line to /etc/sudoers.tmp:
However, the above configuration did not work.
Is there a way to execute sudo commands from InterSystems IRIS Production ObjectScript code in Ubuntu?
Comments
You can execute host operating system commands from ObjectScript by using $ZF(-100), which runs an executable program or system command and returns the operating system/program exit status. [1][2]
The InterSystems Lite Terminal is a WebSocket-based command-line interface for executing ObjectScript commands on a connected server. It starts its terminal process using the JOB command. [3]
The retrieved material does not provide a documented way to elevate privileges with sudo from InterSystems IRIS ObjectScript code, nor does it describe support for interactive sudo password prompting in Lite Terminal or $ZF(-100). [1][3]
It also does not document any specific handling for exit code 127 in this scenario. [1]
What is documented is that if the full path to an executable is not specified in $ZF(-100), the operating system applies standard search path rules. [1]
Note: $ZF(-100) replaces deprecated functions $ZF(-1) and $ZF(-2), and should be preferred in all cases. [1]
Because the available documents do not state whether or how sudo can be used successfully from IRIS Production ObjectScript code on Ubuntu, or how to configure that in Lite Terminal, I cannot confirm a supported method from the provided sources. [1][3]
Sources:
.
s io="whoami" o io:"rq" u io r x u 0 w x
Above command gave username as "irisusr" which was not the user added to /etc/sudoers file.
This was the issue. (User logged in the VM was "ubuntu" and I tried adding this user to the file)
When "irisusr" was added in /etc/sudoers file, sudo commands seems to be working.
Additionally, I tried the command
w $ZF(-100, "/SHELL", "sudo whoami")
which was not correct, it should have been
w $ZF(-100, "/SHELL", "sudo","whoami")
sudo commands are working now.