佳木斯湛栽影视文化发展公司

主頁 > 知識庫 > 一個shell寫的ping函數(shù)

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

熱門標(biāo)簽:網(wǎng)站排名優(yōu)化 Linux服務(wù)器 地方門戶網(wǎng)站 百度競價排名 服務(wù)外包 呼叫中心市場需求 鐵路電話系統(tǒng) AI電銷
復(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檢測$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
您可能感興趣的文章:
  • 防止ARP攻擊的shell代碼
  • 使用shell腳本實現(xiàn)ping對應(yīng)IP所對應(yīng)的人名(推薦)
  • ping發(fā)現(xiàn)掉包報警的shell代碼
  • shell腳本編寫ping包及arp的監(jiān)控并發(fā)送短信功能

標(biāo)簽:仙桃 銅川 湖南 湘潭 衡水 蘭州 崇左 黃山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《一個shell寫的ping函數(shù)》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話咨詢

    • 400-1100-266
    中西区| 中宁县| 绩溪县| 阿勒泰市| 麻阳| 九龙坡区| 东丰县| 横山县| 邵阳县| 长白| 许昌县| 广安市| 崇礼县| 马鞍山市| 石阡县| 大英县| 独山县| 山东| 台中市| 时尚| 临潭县| 陕西省| 深圳市| 西峡县| 平阴县| 江西省| 山阴县| 玉龙| 梁河县| 通山县| 综艺| 新化县| 保亭| 镇平县| 邻水| 永善县| 潞西市| 聂荣县| 宁强县| 丰都县| 六枝特区|