# Ping and IP by expression

**URL:** <https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652>\
**Category:** Ignition\
**Tags:** perspective, ignition81\
**Created:** [March 20, 2024, 6:46pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652 "2024-03-20T18:46:12Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 6:46pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/1 "2024-03-20T18:46:12Z")

</div>

Is there a way to ping an address with an expression? I have a few WAPs that I ould like to ping and get a boolean back.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 20, 2024, 6:52pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/2 "2024-03-20T18:52:56Z")

</div>

There are a few ping utilities in the Ignition Exchange. Here's one:

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2192/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 6:56pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/3 "2024-03-20T18:56:24Z")

</div>

cool ill check it out

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 8:28pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/4 "2024-03-20T20:28:35Z")

</div>

So i downloaded the view and it works great. I want to go a tag route and downloaded/imported a udt:

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2235/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

When I try and use it i get an error saying it cannot execute the expression runScript("NetworkAnalysis.ping")

The script exists in the Scripting of the project:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/454ef29dd744f4e22459c65d00e007b5f3b562b0.png)

I was curious if any suggestions on this?

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [March 20, 2024, 8:30pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/5 "2024-03-20T20:30:19Z")

</div>

scripts executed in a Tag Expression `runScript()` must be located in the Gateway Scripting Project. If you have a Gateway Scripting Project then you should put the script there. If you don't already have one then you should configure one.

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 8:49pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/6 "2024-03-20T20:49:07Z")

</div>

I see. Yes we do I just found it. That took care of it. thank you sir.

---

<div class="post-metadata">

**Author:** ![Arnaud\_Declerck](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/arnaud_declerck/32/44872_2.png) [@Arnaud\_Declerck](https://forum.inductiveautomation.com/u/Arnaud_Declerck)\
**Post date:** [March 20, 2024, 8:55pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/7 "2024-03-20T20:55:17Z")

</div>

I've just response to your email with the same tips as @lrose give you.

Just as feedback, was it not clear enough in the installation steps on the exchange ressource? How can i made more clear for the next person using it?

Regards

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 9:19pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/8 "2024-03-20T21:19:11Z")

</div>

That same email you sent me really cleared things up. The pics were most helpful. It's a great udt!

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 20, 2024, 9:32pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/9 "2024-03-20T21:32:51Z")

</div>

Oy! Someone share the pics.

I didn't mention the name of the Exchange project. To help with search indexing here it is.

[Network Device Status By: Bao Nguyen](https://inductiveautomation.com/exchange/2192/overview).

---

<div class="post-metadata">

**Author:** ![mjohnson0238](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@mjohnson0238](https://forum.inductiveautomation.com/u/mjohnson0238)\
**Post date:** [March 20, 2024, 9:49pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/10 "2024-03-20T21:49:18Z")

</div>

Here they are:

![image003.png](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/a/5aae06432b8404f6a68611bcaefc243612031a27.png)

 ![image004.png](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/9/e9a8eebf96bf0bfe643207082859608401cea445.png)

---

<div class="post-metadata">

**Author:** ![Tom-L](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@Tom-L](https://forum.inductiveautomation.com/u/Tom-L)\
**Post date:** [January 5, 2025, 4:40am UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/11 "2025-01-05T04:40:55Z")

</div>

I see lots of posts saying "don't use runScript!" from years ago, but this project uses it. Does that rule still apply? Or is there a more preferred way to use ping to monitor device status than in a fixed rate runScript from tags (Perspective)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2025, 3:11pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/12 "2025-01-05T15:11:56Z")

</div>

Don't use `runScript()` for this kind of task, particularly not in expression tags. If you need to monitor a list of target devices, use a timer event and write the results to memory tag(s).

Consider using java's built-in "ping" support via [InetAddress.isReachable()](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/net/InetAddress.html#isReachable(int)). (On linux, this requires `CAP_NET_RAW`.)

---

<div class="post-metadata">

**Author:** ![Tom-L](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@Tom-L](https://forum.inductiveautomation.com/u/Tom-L)\
**Post date:** [January 5, 2025, 3:52pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/13 "2025-01-05T15:52:59Z")

</div>

Thanks for confirming. The script does use the Java ping but it’s invoked by runscript. I’ll create a timer script instead so it’s also in one place.  
I did notice the runscript will write to the tags even with comms off, convenient but potentially dangerous, but good for testing. Is there a way to have comms off as a global but allow certain tags to be written?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [January 5, 2025, 4:53pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/14 "2025-01-05T16:53:44Z")

</div>

Comms control is a designer-specific function, not available nor meaningful in gateway scope.

---

<div class="post-metadata">

**Author:** ![Tom-L](https://avatars.discourse-cdn.com/v4/letter/t/50afbb/32.png) [@Tom-L](https://forum.inductiveautomation.com/u/Tom-L)\
**Post date:** [January 5, 2025, 4:55pm UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/15 "2025-01-05T16:55:35Z")

</div>

Ah, yes, understood, thanks

---

<div class="post-metadata">

**Author:** ![cristhian.rivera](https://avatars.discourse-cdn.com/v4/letter/c/c89c15/32.png) [@cristhian.rivera](https://forum.inductiveautomation.com/u/cristhian.rivera)\
**Post date:** [September 11, 2025, 3:21am UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/16 "2025-09-11T03:21:42Z")

</div>

I have a problem when evaluating an IP address.  
I get `Error_ExpressionEval` in the expression tag of _isConnected_. Do you have any idea why this error appears?  
The IP address I’m pointing to is a valid one.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/6/76628c3f0a3775ee1b589fac5c69278dbbfb2569.png)

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [September 11, 2025, 3:58am UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/17 "2025-09-11T03:58:21Z")

</div>

Is your project defined as the gateway scripting project in the gateway settings?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [September 11, 2025, 11:34am UTC](https://forum.inductiveautomation.com/t/ping-and-ip-by-expression/87652/18 "2025-09-11T11:34:21Z")

</div>

1. move the `import` _outside_ the def, so it only happens once.
2. Java's `.isReachable()` method requires `CAP_NET_RAW` in Linux, which is normally not available to non-root service users. You get a permissions error if not set as an extra permission in your service (SystemD). I'm not sure about Windows.

You should test your function outside of runScript (but still in gateway scope) to be sure it works that way.
