查看是否ping通网站 [cpp] #!/bin/bash #Checks to see if hosts 192.168.1.100-192.168.1.200 are alive for n in {100200}; do host=192.168.1.$n ping -c 2 $host >/dev/null if [ $ = 0 ]; then echo "$host is UP" else echo "$host is DOWN" fi done 读网站文本 [cpp] #!/bin/bash while read host do ping -c 2 $host >/dev/null if [ $ = 0 ] then echo "$host" else echo "$hostN" fi done < domain.txt |