Detect the host is alive

#!/bin/bash
PREFIX=192.168.1
 NODE=1
 while [ "$NODE" -lt "255" ]; do
 echo -en "Pinging ${PREFIX}.${NODE}..."
 ping -c1 -w1 -t5 ${PREFIX}.${NODE} >/dev/null 2>&1
 if [ "$?" -eq "0" ]; then
 echo "OK"
 else
 echo "Failed"
 fi
 let NODE=$NODE+1
 done
Please indicate the source: http: //www.ttlsa.com/html/678.html

Reproduced in: https: //my.oschina.net/766/blog/211542

Guess you like

Origin blog.csdn.net/weixin_33828101/article/details/91492991