ip批量连接测试

#!/bin/bash
#Program:
#	scan the ip from $1 to $2 ,output the ip which your can connect
#History:
#	build by AstrayLinux in 2011/10/19
PATH=/home/ocean/bin/script:/home/ocean/bin:/home/ocean/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
export PATH

	net=""
	net=`echo $1 | cut -d '.' -f 1`
	net=${net}.`echo $1 | cut -d '.' -f 2`
	net=${net}.`echo $1 | cut -d '.' -f 3`
	
	ips=`echo $1 | cut -d '.' -f 4`
	ipb=`echo $2 | cut -d '.' -f 4`
	if [ "$net" == "" ] || [ "$ipb" == "" ] || [ "$ips" == "" ];then 
		echo "The parmers wrong!"	
		exit 1
	fi

	i=1	
	while [ $ips -le $ipb ]
	do 
		ping -c 1 -w 0.5 -i 0.5  ${net}.${ips} &> /dev/null && result=0 || result=1
		if [ $result == 0 ];then
			str=`ping -c 1 -w 0.5 -i 0.5  ${net}.${ips} | awk 'NR==2 {print $7}'`
			printf "%3s : " $i
			echo "Server ${net}.${ips} is up " $str 
			i=$(( $i+1 ))
		fi
		ips=$(( $ips+1 ))
	done
exit 0

测试的两个IP必须在同一网段内
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值