题目如下:#!/bin/bash#the script's name is:*********use to test the host********* #the author is :Ro#the version is :Ro-4-10let PIP=$1NetIP='192.168.1.' if [ $1 -gt 254 ];then echo "The fist number should <=254" elif [ $2 -gt 254 ];then echo "The second number should <=254" elif [ $1 -gt $2 ];then echo "The first number should <= the second number" else while [ $PIP -le $2 ];do ping -c1 -W1 $NetIP$PIP > /dev/null && echo "The host $NetIP$PIP is UP." 》 /tmp/host_state || echo "The host $NetIP$PIP is DOWN." 》 /tmp/host_state let PIP++ done echo "==============================" cat /tmp/host_state echo "==============================" sed '1,$s/\(.*DOWN\)./#\1/g' /tmp/host_state echo "==============================" sort -t " " -k 5 /tmp/host_state | cut -d" " -f5 | uniq -c echo "==============================" rm -rf /tmp/host_state fi测试结果: |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|