Created
July 18, 2012 00:30
-
-
Save rcaldwel/3133188 to your computer and use it in GitHub Desktop.
unix: take host list from stdin and check ping
This file contains hidden or 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 | |
# 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