Skip to content

Instantly share code, notes, and snippets.

@rcaldwel
Created July 18, 2012 00:30
Show Gist options
  • Save rcaldwel/3133188 to your computer and use it in GitHub Desktop.
Save rcaldwel/3133188 to your computer and use it in GitHub Desktop.
unix: take host list from stdin and check ping
#!/bin/bash
# take a list of hosts by stdin and ping them
while read line; do
RESULT=`ping -c1 $line >/dev/null 2>&1 || echo 'fail'`
if [ "$RESULT" = "" ]; then
RESULT="pass"
fi
echo "$line -> $RESULT"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment