国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > Linux Shell > 正文

一個(gè)shell寫的ping函數(shù)

2020-07-27 19:26:01
字體:
供稿:網(wǎng)友
復(fù)制代碼 代碼如下:

#!/bin/bash
#2013-01-06 14:00:00 wanggy exp
#note:ping monitor
set -u
#set -x
ping_fun()
{
    d_network=192.168.1
    echo -n "input the network(default $d_network):"
    read network
    : ${network:=$d_network}
    echo "network:$network"
    d_hostip_beg=1
    d_hostip_end=254
    echo -n "input the hostip(default $d_hostip_beg $d_hostip_end):"
    read hostip_beg hostip_end
    : ${hostip_beg:=$d_hostip_beg}
    : ${hostip_end:=$d_hostip_end}
    echo "hostip_beg:$hostip_beg"
    echo "hostip_end:$hostip_end"
    count=3
    for ((hostip=$hostip_beg;hostip<=$hostip_end;hostip++));do
            host=$network.$hostip
            echo "開始ping檢測(cè)$host"
            ping -c $count $host &>/dev/null
                    if [ $? = 0 ];then
                            echo "$host is up"
                    else
                            sleep 3
                            ping -c $count $host &>/dev/null
                            if [ $? = 0 ];then
                                    echo "$host is up"
                            else
                                    echo "$host is down"
                            fi
                    fi
            done
    #echo "執(zhí)行完畢"
    exit 0
    }
    main()
    {
    echo "----開始執(zhí)行ping程序----"
    ping_fun
    }
    main
    exit 0
發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 正阳县| 犍为县| 绿春县| 阿合奇县| 武宁县| 三原县| 六盘水市| 香河县| 铜陵市| 乐东| 镇远县| 上虞市| 宝应县| 广汉市| 肥乡县| 弥勒县| 蓬莱市| 花莲市| 林西县| 亳州市| 大邑县| 兴安盟| 佳木斯市| 桦甸市| 东平县| 渝中区| 娄烦县| 富蕴县| 苏尼特右旗| 北宁市| 龙门县| 宜丰县| 达尔| 宜春市| 江阴市| 怀来县| 会东县| 深泽县| 景德镇市| 武汉市| 木兰县|