I have a piece of a script that is not working right. I make an array from a host list, then use a for loop to ping each host in the array. In the test host list I have localhost, 127.0.0.1, and 10.3.2.1. The point of this is to test that host names will work as well as IP addresses, and that the localhost and loop back will work and 10.3.2.1 will fail because 10.3.2.1 doesn't exist.
When I run the script, the ping command only runs against 10.3.2.1, and does nothing for localhost and 127.0.0.1. If I throw in an echo statement to see if all elements in the array are being read, it returns all 3 hosts.
declare -a Hosts
Hosts=$(grep "^[^#;]" ../Configuration/HostList
for h in "${Hosts[@]}"
do
ping -c1 $h
done
Again, when this runs, it only pings 10.3.2.1. I need it to ping localhost, 127.0.0.1, and 10.3.2.1.