# Script to ping computer

**URL:** <https://forum.inductiveautomation.com/t/script-to-ping-computer/16612>\
**Category:** Ignition\
**Created:** [January 16, 2018, 6:27pm UTC](https://forum.inductiveautomation.com/t/script-to-ping-computer/16612 "2018-01-16T18:27:35Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![silverbacknet](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/silverbacknet/32/7385_2.png) [@silverbacknet](https://forum.inductiveautomation.com/u/silverbacknet)\
**Post date:** [May 29, 2020, 10:30pm UTC](https://forum.inductiveautomation.com/t/script-to-ping-computer/16612/10 "2020-05-29T22:30:23Z")

</div>

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:

```auto
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 of not even knowing it happened unless you parse unexpected command-line output. Or just swallow exceptions, of course.

[java.net](http://java.net).\* can do all the fun things you thought you needed command-line tools for, and more.

---

_[View the full topic](https://forum.inductiveautomation.com/t/script-to-ping-computer/16612)._
