sh脚本:批量ping

    xiaoxiao2021-12-14  23

    #! /bin/sh ## confirm params if [ `echo $* | awk '{print NF}'` -eq 0 ];then echo "please select a file!" exit 0 fi ## confirm file path file=$1 if [ `expr match $file '/'` -eq 0 ];then file=`pwd`/$file fi if [ -e $file -a -f $file ];then echo "begin~" else echo "not exists : $file" exit 0 fi ## do ping for 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 fi done

    转载请注明原文地址: https://ju.6miu.com/read-968460.html

    最新回复(0)