PicOS switches support ping, which may be used to test connectivity to remote IP addresses. Users often want to test connectivity to all subnets in their network. This can be accomplished manually by pinging IP addresses in all subnets one-by-one, but that method is error-prone and tedious.
This section describes how to write a simple re-usable script to ping a number of IP addresses at once. This script is especially useful when troubleshooting connectivity in a network, and user needs to ping a number of IP addresses again and again for verification.
User can create the script once and use it again and again from the PicOS L2/L3 operation mode.
This requires a text editor to create the script and save it as a file on user's PicOS switch. PicOS includes the vi text editor, which can be run from the Linux shell on user's PicOS switch. We choose to call our script pingAll.sh though user may choose any other name. The .sh file extension is not mandatory, though we recommend using it to make it obvious to anyone that the file is a shell script.
Inside the vi editor, press i to be able to insert text. Paste the following lines of text (after modifying them for user's network):
Press Esc and then enter :wq to save the file and exit the vi editor.
Some information about the script follows. The ip array has thirteen elements (ip – ip) and each element holds an IP address. User can change both the IP addresses and the number of array elements. The script will send three ping requests to each IP address in the ip array, one by one. If user is familiar with shell scripting or programming in C-like languages, the script should be self-descriptive. Even if user is an absolute beginner to programming and scripting, user should be able to modify and use the script after some research.
List the contents of user's home directory.
Make the new file pingAll.sh executable.
Enter the PicOS L2/L3 operation mode.
Run the script from PicOS L2/L3 operation mode.