Last active
February 26, 2025 11:04
-
-
Save dgibbs64/05c5aabea934fcb8c34cd87e4b60ef5b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Read the hosts from the file into an array | |
mapfile -t hosts < hosts.txt | |
# Loop through each host | |
for host in "${hosts[@]}"; do | |
ping -c 1 -w 1 "$host" >/dev/null | |
if [ $? -eq 0 ]; then | |
echo "Resolving $host: PASS" | |
elif [ $? -eq 1 ]; then | |
echo "Resolving $host: PASS" | |
elif [ $? -eq 2 ]; then | |
echo "Resolving $host: FAIL" | |
else | |
echo "Resolving $host: FAIL" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment