Quantcast
Channel: NETWORK ENGINEER BLOG
Viewing all articles
Browse latest Browse all 266

CentOS の Ping で Timeout を表示

$
0
0

CentOS で Ping を実行した際、Windows のように"Request Timed out"を表示させる方法です。

# host=***.***.***.***; max_cnt=10; cnt=0; while [ $cnt -le $max_cnt ]; do rslt=`ping -w 1 -c 1 $host | grep 'bytes from '`; if [ $? -gt 0 ]; then echo -e "`date +'%H:%M:%S'` $host Request timed out."; else echo "`date +'%H:%M:%S'` $host`echo $rslt | cut -d  ':' -f 2`"; sleep 1; fi; cnt=$(expr $cnt + 1); done

Viewing all articles
Browse latest Browse all 266

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>