1. 程式人生 > >查看局域網內存活主機

查看局域網內存活主機

ping shell

#!/bin/bash
#20170824
#Check the network is online
read -p "Enter your network segment(example 192.168.1.):" ip_num
echo "Please wait..."
for i in `seq 1 254`
do
ping -c 2 -W 1 $ip_num$i >/dev/null
        if [ $? -eq 0 ];then
                echo "echo $ip_num$i is up"
                echo $ip_num$i is up > ip_yes.txt
        else
                echo "echo $ip_num$i is down"
                echo echo $ip_num$i is down > ip_no.txt
        fi
done
exit 0


本文出自 “天真無邪” 博客,請務必保留此出處http://innocence.blog.51cto.com/4313888/1958852

查看局域網內存活主機