# Device connected and pinger script does not work

**URL:** <https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [June 9, 2020, 12:35pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452 "2020-06-09T12:35:43Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 9, 2020, 12:35pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/1 "2020-06-09T12:35:43Z")

</div>

Hello,

I use Ignition 7.9.12 for supervision application. In this application, i created a pinger script :

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/e/e1973fdaa6dd35e80688243af7d215b1f4c4e45e.png)  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/7/73189424f3f658b51687a69ff7c2c6f073f9d074.png)

In the application i created a view for dispay the connection status of the connected equipment. On my computer this view work correctly and the label ‘CENNECTED’ is displayed for connected equipment.  
But the panel PC Pro-face SP5000 that is used for this project, the label ‘CENNECTED’ is not displayed for connected equipment. Despite the equipment is correctly connected and display as connected on OPC-UA Server\> Devices.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/2X/0/0b832b70fcc6b0c17988472fcb8db5e692d28e3e.png)

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 9, 2020, 3:39pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/2 "2020-06-09T15:39:19Z")

</div>

Try this native Java script instead of using command line:

> [@Script to ping computer](http://forum.inductiveautomation.com/t/script-to-ping-computer/16612/10):
>
> Shelling out for this makes me feel very icky, especially when Java already has the native ability to do this and that’s an invitation to accidentally send horrible things to the command line. Why not just: def ping(address,timeout=2000): from java.net import InetAddress ip = InetAddress.getByName(address) return ip.isReachable(timeout) This will throw UnknownHostException if the host can’t be looked up, or IOException if the network is broken, so you can handle that case as well, instead o…

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 9, 2020, 5:15pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/3 "2020-06-09T17:15:54Z")

</div>

It is the some problem. I replaced the script and it was the some result.

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 9, 2020, 6:15pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/4 "2020-06-09T18:15:37Z")

</div>

Have you confirmed that you can ping the devices from outside of Ignition using cmd/terminal? Network switch blocking pings? Devices set to not respond to pings?

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 9, 2020, 6:30pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/5 "2020-06-09T18:30:25Z")

</div>

Yes. I can ping the device throw cmd/terminal correctly. Also, the devices is displayed connected on OPC-UA Server\> Devices and the tags change when PLC IO change.  
I tried to connected the device directly to the panel PC without success.

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 11, 2020, 2:15pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/6 "2020-06-11T14:15:18Z")

</div>

Does calling the shared script from the script console work as expected? Or does it fail to give the results you’re looking for there too?

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 11, 2020, 3:35pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/7 "2020-06-11T15:35:18Z")

</div>

The some application work in other stations. And in the SP5000 Pro-Face panel PC does not work.  
That mean that the script is well created and called in the Ignition application.  
May be there is some setting that must be checked wich I do not know!!!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 11, 2020, 4:01pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/8 "2020-06-11T16:01:52Z")

</div>

Yes, this likely relates to network settings/configuration on the SP5000 in some way. I’m not sure what could be stopping this if you can ping the same address from command prompt on the SP5000.

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 11, 2020, 4:20pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/9 "2020-06-11T16:20:17Z")

</div>

I can ping all the device with the cmd/terminal. So i do not understand where is the problem !!

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [June 11, 2020, 5:06pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/10 "2020-06-11T17:06:04Z")

</div>

That is strange. Is the gateway running on the SP5000, or elsewhere? If the SP5000 is just a client (not also the gateway), it isn’t relevant as this script in a tag would be running on the gateway.

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 11, 2020, 5:18pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/11 "2020-06-11T17:18:22Z")

</div>

The gateway is running on the SP5000.

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 11, 2020, 7:58pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/12 "2020-06-11T19:58:07Z")

</div>

Retracted my original post as I had to re-read the last couple posts…

For the PLCs, you could reference the “Diagnostics/Is Connected” tag instead of trying to ping them.

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 11, 2020, 8:48pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/13 "2020-06-11T20:48:36Z")

</div>

I could not get the version of the ping function you have to work (one note, your command variable should be a python list[]). This version is what I use in my projects:

```auto
def ping(ip):
	import subprocess
	import platform
	
	# Ping command depends on OS
	platform_cmd = '-n' if platform.system() == 'Windows' else '-c'
	command = ['ping', platform_cmd, '1', ip]
	resp = subprocess.Popen(command, stdout=subprocess.PIPE).stdout.read()
	
	return False if 'unreachable' in resp.lower() else True

```

In the future if you could copy your code into your message (enclosed with ```), instead of a screenshot, it will make it a lot easier for us to help you.

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [June 11, 2020, 9:12pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/14 "2020-06-11T21:12:29Z")

</div>

As @witman said, Java has its own native icmp library you can use instead of going through the OS

> [@Device connected and pinger script does not work](http://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/2):
>
> Try this native Java script instead of using command line:

---

<div class="post-metadata">

**Author:** ![WillMT10](https://avatars.discourse-cdn.com/v4/letter/w/7feea3/32.png) [@WillMT10](https://forum.inductiveautomation.com/u/WillMT10)\
**Post date:** [June 11, 2020, 9:31pm UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/15 "2020-06-11T21:31:14Z")

</div>

To expand on @nminchin’s response. Can you give more detail into any errors or tests you ran when you tried using the native Java approach? I only offered the modified python version because you weren’t able to get the Java function working.

---

<div class="post-metadata">

**Author:** ![marwane.gannoun](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/marwane.gannoun/32/15701_2.png) [@marwane.gannoun](https://forum.inductiveautomation.com/u/marwane.gannoun)\
**Post date:** [June 12, 2020, 6:53am UTC](https://forum.inductiveautomation.com/t/device-connected-and-pinger-script-does-not-work/35452/16 "2020-06-12T06:53:12Z")

</div>

I used the native Java approach and the some problem.

I reinstalled the windows 10 IOT 2016 that was installed on the SP5000 and also i have the some issue.  
So i made a clone of my PC windows and i installed it on the SP5000. The problem is solved and the ping script work !!!
