System.util.execute() not working in Linux: how do I run external shell script from Ignition?

Hello, All,
I am trying to call external shell script from Ignition running under Linux with using system.util.execute() command and still did not succeed. At the same time, calling bat-script under Windows works fine with using the following command
system.util.execute([“C:\windows\system32\cmd.exe”,"/C",“start”,“C:<path_to_script>\test.bat”])

Example at https://support.inductiveautomation.com/usermanuals/ignition/index.html?system_util_execute.htm is for Windows, but there is not example for Linux. I tried system.util.execute(["/bin/sh"]), system.util.execute(["/bin/sh", “ls”, “-la”]), system.util.execute(["/bin/bash", “ls”]), system.util.execute(["/bin/sh", <path_to_my_script>]) but no success.
I would really appreciate any help on that

How are you evaluating whether those commands executed successfully or not? Is there an IOException being thrown or does system.util.execute invoke without error?

Hello, Kevin,
Thanks for responding. There is no IO exception, just my command system.util.execute([]) is not executed. IO exception raises when there is an error on the path to my script, for example. When I run the following command in Windows:
system.util.execute([“C:\windows\system32\cmd.exe”,"/C",“start”,“C:\path_to_myscript\test.bat”])

it works fine - terminal window shows up and my script test.bat is executed. I am looking for some example how to do the same thing in Ignition under Linux.
P.S. Based on other related topic from this forum, I also tried to run
system.util.execute([“sh”, “/home/path_to_myscript.sh”, “shell=True”]) and system.util.execute([“sh”, “/home/path_to_myscript.sh”]) - still no success, nothing happens, no error, script is not executed

1 Like

I don’t think you can expect a terminal to show up on Linux by executing/invoking bash. Your shell doesn’t have a GUI. You need to try to open a terminal emulator like xterm or something.

OK, but can I expect my shell script to be executed?

Yes, but don’t expect to see anything.

1 Like

Thank you, Kevin. There was an error in my shell script. I fixed it and now the script is executed fine!

I followed the exact process. I am not getting only success in status but the script is not executing... I tried all the ways you suggested. My shell script worked when ran in terminal, but ignition is not able to run it. Also I gave a file that does not exist to see if I get error from the gateway script. Still I get success and no indication of file not found error. I urgently need help.
My gateway script looks like this:
system.util.execute(["sh","/home/ubuntu/pilotCall.sh"])

system.util.execute() never returns any status. It is a completely blind, unaimed, "fire-and-forget" weapon tool.

Use java's ProcessBuilder to run your script, with reading of the process' stdout and stderr streams to see what is happening.