Shell script implements bulk test LAN host whether online _linux shell

Source: Internet
Author: User

Because the local area network host many, the VLAN also many, for often can know the number of on-line host, writes the script to examine the on-line host.

The effect is: the host online display green, the host offline display red results.

Usage:./ping IP Segment For example:./ping 192.168.0

Copy Code code as follows:

#!/bin/bash
Network=$1
for HOST in $ (SEQ 1 254)
do
&nb sp;       ping-c 1-w 1 $NETWORK. $HOST &>/dev/null && result=0 | | Result=1
                If ["$ Result "= = 0];then
                         echo-e "\033[32;1m$network. $HOST is up! \033[0m "
                else
                         echo-e "\033[;31m$network. $HOST is down!\033[0m"
     & nbsp;          fi
Done

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.