Skip to content

Instantly share code, notes, and snippets.

@dreambo4
Last active April 24, 2024 01:04
Show Gist options
  • Save dreambo4/b189aeff8ede85e8fcdd73651195f775 to your computer and use it in GitHub Desktop.
Save dreambo4/b189aeff8ede85e8fcdd73651195f775 to your computer and use it in GitHub Desktop.
Thanks chatGPT!
#!/bin/bash
# Replace with the IP address you want to ping
IPArray=(
"192.168.0.1"
"192.168.0.2"
"192.168.0.3"
"192.168.0.4"
"192.168.0.5"
)
COUNT=1 # Number of ping attempts
TIMEOUT=5 # Ping timeout in seconds
for IP in "${IPArray[@]}"; do
if ping -c $COUNT -W $TIMEOUT "$IP" > /dev/null 2>&1; then
echo "Ping to $IP was successful."
else
echo "Ping to $IP failed."
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment