Shell Check Company surviving PC

Source: Internet
Author: User

If the leader tells you to check the company when you're off duty. Those PCs are open, one to see? NO, it's too much trouble. The following script can quickly find the surviving PC through the ICMP ping packet, it is important to note that the local host will be the same as the subnet mask of the target host, and also at the same address bit.




#!/bin/bash

Read-p "Please enter start IP:" bigin_ip

Read-p "Please enter end IP:" over_ip

Ip_net= ' echo $bigin _ip|cut-d. -F 1-3 '

B_num= ' echo $bigin _ip|cut-d. -F 4 '

O_num= ' echo $over _ip|cut-d. -F 4 '

Echo $ip _net

Echo $b _num

Echo $o _num

For i in ' SEQ 1 3 '

Do

For b_cut in ' Echo $bigin _ip| Cut-d. -F $i '

Do

for O_cut in ' Echo $over _ip|cut-d. -F $i '

Do

If [$b _cut-ne $o _cut]

Then

echo "Please enter IP of the same address bit"

Else

While [$b _num-le $o _num]

Do

Ping-c 2-i 0.2 $ip _net. $b _num &>/dev/null

If [$? = 0]

Then

echo "$ip _net. $b _num is Alive"

Fi

Let b_num++

Done

Fi

Done

Done

Done


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/54/25/wKiom1R5cPqRs3w6AAC8Rkf_Xio308.jpg "title=" Qq20141129145817.png "alt=" Wkiom1r5cpqrs3w6aac8rkf_xio308.jpg "/>


This paper is transferred from Visia Comprehensive Forum: http://www.w4ya.com/thread-91-1-1.html

This article from "Dragon Love Xue Qi" blog, declined reprint!

Shell Check Company surviving PC

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.