Continuously Ping a Domain Using System Exec in LabVIEW on Windows

Updated Aug 30, 2023

Environment

Software

  • LabVIEW

Operating System

  • Windows

Other

  • Windows OS

When working on a network, you might need to check whether one of the network components is still connected. One of the ways to do that is to ping that component by either using its domain name, IP or URL. On a Windows machine, one of the tools that allow you to do that is the command prompt (cmd). LabVIEW allows you to use the cmd through the System Exec function. For more information about it, click here. For a general overview about how to ping using the System Exec function, click here.

If the need arises to check the connection with this component continuously, follow the below steps.

1. To keep running the ping command, use a while loop and a shift register.

2. Notice the end of line constant, it's there to actually run the command. It is the equivalent of pressing the Return key after typing in the command in cmd.

3. Use the Match Regular Expression to get the IP address from the output of the cmd. This allows to get the IP address if the input is a domain name or URL.

4. The working directory is different for each scenario.

Ping.png
NoteIn order to use this snippet, download this image, and then drag and drop it on your LabVIEW block diagram.

The resulting VI pings a domain name, URL or IP address continuously until stopped.