您的位置:首页 > 运维架构 > Shell

shell 内网主机存活探测器

2014-12-18 16:02 579 查看
最近在学习shell 编程,闲来无事,搞了一个小shell. 可以用来 对一个网段的存活主机进行 探测。

#!/bin/bash
#
#date:2014/12/18
#blog:www.cnblogs.com/outline
#by :Joe

if [ $# -lt 1 ] ; then
echo " err, usage: ping.sh ARg "
echo " eg : ping.sh  192.168.1"
exit 8
fi

ips="$1"
stat=1
for ip in $(seq 1 254)
do
ping -c 1 ${ips}.${ip} >/dev/null && stat=1 || stat=0
if [ $stat -eq 1 ];then
echo " $ips.$ip is up"

fi
done

if [ $stat -eq 1 ]; then
echo " no host up"
fi


.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: