What is the right way to utilize 'system.util.execute' to execute a shell srtipt in Linux?

Hey Guys:
I have a python file and a shell file which are both executable and their folders are readable in the hierarchy, all of which are created under root user.
The problem is, I used a messagehandler to pass the command

and I am not able to create a foler through this shell ‘mkdir.sh’
image
image
I can run this shell using command ‘./mkdir.sh’ but when I run "system.util.sendRequest(‘project_name’, ‘pingCheck’) " in the Script Console, nothing happend.
It really bothers me cause I really need to be able to run shell command in linux through Ignition.
Thank you for your incoming help!! Sincerely!!.

mmm ones I executed bash with util.execute. Try just by passing

/home/.../x.sh

and not include “bin/bash”

I would recommend to avoid this approach if you want to ping an ip, read this reference InetAddress (Java Platform SE 7 ) (oracle.com)

Yes you are amazing, I do wanna ping an ip through this way :joy: :joy: :joy: And I am sorry but I dont get your reference.

I tried just pass ‘/home/…/x.sh’ but there is still no signal that the shell script is executed.


Also, I tried to delete a file using ‘rm -rf’ and it worked which makes more confused that what on earth is wrong with the shell.

You may place this where ever you need but there’s a example in a button:

image

script:

from java.net import InetAddress
timeout = 300
ipAddress = '10.0.30.1'
ipInet = InetAddress.getByName(ipAddress)
reachable = ipInet.isReachable(timeout)
if reachable:
	print 'woh, successfully ping to '+ipAddress
else:
	print ":´( ping to "+ipAddress+' failed in '+str(timeout)+'ms'

Thank you my friend.

Now I can ping an ip using your method. I really appreciate your help!! Thank you a lot!!!

On the other hand, I think I still need my gateway to execute some linux command some day in the future. So it is important for me to figure out how to control the ‘system.util.execute’ to run a python script or a shell script. :pray: :pray: :pray: :pray: