Skip to content

Instantly share code, notes, and snippets.

@dgibbs64
Last active February 26, 2025 11:04
Show Gist options
  • Save dgibbs64/05c5aabea934fcb8c34cd87e4b60ef5b to your computer and use it in GitHub Desktop.
Save dgibbs64/05c5aabea934fcb8c34cd87e4b60ef5b to your computer and use it in GitHub Desktop.
#!/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