sh脚本:批量ping

来源:互联网 发布:公众号排名优化 编辑:程序博客网 时间:2024/04/24 22:00


#! /bin/sh## confirm paramsif [ `echo $* | awk '{print NF}'` -eq 0 ];then        echo "please select a file!"        exit 0fi## confirm file pathfile=$1if [ `expr match $file '/'` -eq 0 ];then        file=`pwd`/$filefiif [ -e $file -a -f $file ];then        echo "begin~"else        echo "not exists : $file"        exit 0fi## do pingfor line in `cat $file`do        res=`ping -c 1 $line | grep loss|awk '{print $6}'|awk -F "%" '{print $1}'`        if [ $res -eq 100 ];then                echo ping \"$line\" \t\t fail        else                echo ping \"$line\" \t\t ok        fidone


0 0
原创粉丝点击