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

首頁 > 系統 > Linux > 正文

一個shell寫的ping函數

2019-10-26 18:35:30
字體:
來源:轉載
供稿:網友
代碼如下:
#!/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檢測$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
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 德清县| 鹰潭市| 嘉禾县| 武威市| 景德镇市| 富裕县| 景东| 介休市| 略阳县| 汨罗市| 万荣县| 龙游县| 麦盖提县| 澳门| 临海市| 卢龙县| 留坝县| 彭水| 张家口市| 长武县| 临洮县| 沂南县| 札达县| 大方县| 岳阳县| 会理县| 临海市| 平南县| 辽宁省| 连城县| 贵港市| 庆元县| 阿克苏市| 西藏| 剑川县| 奉新县| 泗水县| 许昌县| 喀喇沁旗| 辽源市| 卢龙县|