#!/bin/bash
#author:dcc
#date:2018/05/25
#version:v1
#description:test the PC whether up ,you must appoint a NET ID
if [ -z $1 ];then
echo "Error:you must appoint a NET ID"
exit 1
fi
test01=`echo $1 | awk -F . ‘{print $4}‘`
if [ ! $test01 -eq 0 ];then
echo "Error:please appoint a right NET ID"
exit 2
fi
tmp=$1
ID=${tmp%%0*}
for i in {1..254}
do
ping -c 3 -i 0.3 -W 1 $ID$i &> /dev/null
if [ ! $? -eq 0 ];then
echo "$ID$i is down"
else
echo "$ID$i is up"
fi
done
-i ping间隔秒数
-w ping失败的等待时间
原文:https://www.cnblogs.com/dccrussell/p/9090241.html