Created
January 20, 2012 09:26
-
-
Save wynemo/1646382 to your computer and use it in GitHub Desktop.
ping ip range
This file contains 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 | |
checkalive (){ | |
NODE=$1 | |
ping -c 3 $NODE>/dev/null 2>&1 | |
if [ $? -eq 0 ] | |
then | |
echo "$NODE is alive" | |
else | |
echo "$NODE is not alive" | |
fi | |
} | |
input="$1" | |
ips=$(echo ${input%.*}.) | |
start=$(echo ${input##*.} | awk -F- '{print $1}') | |
end=$(echo ${input##*.} | awk -F- '{print $2}') | |
echo $start | |
echo $end | |
for(( i=$start;i<=$end;i++ )) | |
do | |
ip="$ips$i" | |
checkalive $ip | |
done | |
#检测ip ./ip1.sh 199.59.149.1-254 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment