This is related to Using 3rd python library: pyping
I can't get ping to work with popen as of Ignition 8.1. Kind of...
In the script tool on 8.1 or 8.1.5 (pulled from Docker), I have:
from subprocess import Popen, PIPE
entry = Addresses[1]
args = ["ping", "-n","1", "-w","300", "192.168.1.122"]
print(str(args))
p = Popen(args, stdout=PIPE, stderr=PIPE, stdin=PIPE)
output = p.stdout.read()
#print("output = " + output)
err = p.stderr.read()
#print("err = " + err)
Strout = output.decode('UTF-8')
print Strout
This works just fine. However, if I place a button on a Perspective view, and have this code:
logger = system.util.getLogger(WhosHomeLogger)|
from subprocess import Popen, PIPE|
entry = Addresses[0]|
args = [ping, -n,1, -w,300, "192.168.1.122" ]
args = [ls,gwcmd.sh]|
args = [ping,192.168.1.122]|
logger.info(str(args))|
# p = Popen(args , stdout=PIPE) # , stderr=PIPE, stdin=PIPE)|
p = Popen(ping -n 1 www.google.com,stdout = PIPE)|
output,err = p.communicate()|
logger.info(pingoutput = + output)|
and I get the following on the logger:
Error running action 'component.onActionPerformed' on View@C/root/Button: Traceback (most recent call last): File "function:runAction", line 20, in runAction File "/usr/local/share/ignition/user-lib/pylib/subprocess.py", line 859, in init self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/share/ignition/user-lib/pylib/subprocess.py", line 1369, in _execute_child raise OSError(errno.ENOENT, os.strerror(errno.ENOENT)) OSError: [Errno 2] No such file or directory
This works just fine, however, in both script tool and on a button, in 8.0.12 (native, not in Docker)
I don't see any differences between the two subprocess.py. I'm sure the fact that it works in the scripting tool and not in Perspective is a significant clue, but not one that does anything for me.