Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize the IP address in the Fast ping Network Segment with shell script

Shulou Source: shulou.com Published: 2022-06-03 18:49:12 09月29日 Update

This article mainly explains how the shell script realizes the IP address in the fast ping network segment. Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "shell script how to achieve fast ping network segment within the IP address" bar!

If you want to see which IP is used in the network segment, credit tray program maker Q can use this fast ping to make a preliminary judgment. You can specify your own test IP segment and sort the test results into files.

#! / bin/bash

# V1.0 2019-09-10

# Ping test shell script by tutor

Clear

> ip-up.txt

> ip-down.txt

While true

Do

Read-p "Please input the ip segment for ping test (like 192.168.100):" segment

If [- z $segment]; then

Segment= "192.168.100"

Fi

Echo-n "the ip segment is ${segment}, are you sure to continue [yzone]?"

Read action

If [- z $action]; then

Break

Fi

If ["$action" = "y"]; then

Break

Fi

Done

Echo "ping test is ready to run!"

For i in {1..254}

Do

{

Ping-c2-W1 ${segment}. ${I} & > / dev/null

If [$?-eq 0]; then

Echo "${segment}. $i is up" & > / dev/null > > ip-up.txt

Else

Echo "${segment}. $i is down" & > / dev/null > > ip-down.txt

Fi

} &

Done

Wait

Sort-n-k 4-t. Ip-up.txt-o ip-up.txt

Cat ip-up.txt

Sort-n-k 4-t. Ip-down.txt-o ip-down.txt

Cat ip-down.txt

Echo "ping test are finished!"

At this point, I believe that the "shell script how to achieve fast ping network segment of IP address" have a deeper understanding, might as well to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Tags: Network segment address script content learning testing practical deeper credit interest practicality practical simple operation file method more friends programs results website Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MySQL vpn Huawei Apple Microsoft