"Shell script" monitors LAN IP online

Source: Internet
Author: User

First, the script function

To determine whether the IP is occupied, the ping rule is considered to be occupied and the results are output to ip_yes.txt and Ip_no.txt, respectively, by means of the ping command detection.


Second, script writing

#!/bin/bash

#Check the network is online

ip_num=192.168.1.

For i in ' SEQ 1 254 '

Do

Ping-c 2 $ip _num$i >/dev/null

If [$? = 0];then

echo "Echo $ip _num$i is yes"

Echo $ip _num$i is yes >> ip_yes.txt

Else

echo "Echo $ip _num$i is no"

Echo Echo $ip _num$i is no >> ip_no.txt

Fi

Done


"Shell script" monitors LAN IP online

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.