Ignition 8.1 - Ping Script

Hi all,

Refer on the code below, I’m trying to ping a site using subprocess.Popen, the expected result is to have the outputs from the console (i.e. Request Timed Out, packets sent/received, etc) be written on a string memory tag. However, nothing is being written on the tag, it seems like the thread is getting lost in the process.

The script is being executed on a timer with the following configuration:

  • Delay Type: Fixed Delay
  • Delay (ms): 30,000
  • Threading: Dedicated

Code:

import subprocess

def ping():
	
	system.tag.writeAsync(paths, values)
	proc = subprocess.Popen(["ping", "-c", "1", "-i", "180", "google.com"], shell=False, stdout=subprocess.PIPE)
	outs,err = proc.communicate()
	
	paths = ["[default]Trial Site/Connectivity/Latency"]
	values = [outs]
	system.tag.writeAsync(paths, values)
	
ping()

Please let me know if you need additional information.

Cheers!

What OS and Ignition version? Any chance you’re running in a Docker container?

Assuming Linux, this thread has some good information about why it might not be working, container or not: Popen with ping doesn't work in a Docker container - #11 by ken.maze

1 Like

Thanks for this! Cheers.