Skip to content

Instantly share code, notes, and snippets.

@towo
Created December 18, 2014 21:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save towo/91d2f8f02cff4ea600d9 to your computer and use it in GitHub Desktop.
Save towo/91d2f8f02cff4ea600d9 to your computer and use it in GitHub Desktop.
Ping check for hosts
#!/bin/sh
# Takes a list of space-separated hosts, FQDN or IP, as parameters.
# Will check each host with just one ping, Vassily, to see if they respond.
# Will print reachability for each host.
# No input validation.
for host in $@; do
echo -n "$host: "
if ping -c1 $host > /dev/null 2>&1; then
echo reachable;
else
echo unreachable;
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment