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

首頁 > 開發 > Linux Shell > 正文

一個可交互的并發ping檢測腳本

2020-07-27 19:25:57
字體:
來源:轉載
供稿:網友
復制代碼 代碼如下:

#!/bin/bash
#********************************#
#2013-01-11 17:00:00 wanggy exp  #
#note:ping monitor               #
#********************************#
set -u
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"
            if [ $hostip_beg -gt $hostip_end ];then
                    echo "$hostip_beg greater than $hostip_end!!!"
                    exit 0
            fi
    : >pinglog
    : >pingerrlog
    ping_count=3
    for ((hostip=$hostip_beg;hostip<=$hostip_end;hostip++));do
    {
            host=$network.$hostip
            echo "開始ping檢測$host"
            ping -c $ping_count $host >/dev/null
                    if [ $? = 0 ];then
                            echo "$host is up"
                            echo "$host is up" >>pinglog
                    else
                                    echo "$host is down"
                                    echo "$host is down" >>pingerrlog
                    fi
}&
   done
wait
}
main()
{
    echo "----開始執行ping程序----"
    ping_fun
}
main
exit 0
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 墨玉县| 洛浦县| 慈溪市| 恩平市| 府谷县| 固原市| 泰来县| 保德县| 集安市| 枞阳县| 孝义市| 潞西市| 内乡县| 平罗县| 阳泉市| 梧州市| 齐齐哈尔市| 出国| 湘阴县| 都江堰市| 札达县| 枞阳县| 修武县| 香港 | 满城县| 阳东县| 登封市| 玉林市| 石棉县| 洱源县| 宜昌市| 灵宝市| 商水县| 云阳县| 威信县| 永清县| 资中县| 新和县| 密云县| 乌兰察布市| 扬中市|