Saturday, April 27, 2024
 Popular · Latest · Hot · Upcoming
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 3259  / 2 Years ago, sun, june 26, 2022, 7:47:04

I need a script that ping a group of ips and return as a result the online one , it will echo for example
10.10.10.10 is online



10.10.10.11 is online



10.10.10.15 is online



Without using any package or third party utility !



Any help ?


More From » ping

 Answers
6

The script below will loop in a subnet ips and return as a result just the online :



#!/bin/bash

is_alive_ping()
{
ping -c 1 $1 > /dev/null
[ $? -eq 0 ] && echo Node with IP: $i is Online.
}

for i in 10.1.1.{1..255}
do
is_alive_ping $i & disown
done


Note change 10.1.1. to you subnet , a 1..255 tell the script to start from 10.1.1.1 and loop tell 10.1.1.255



Execute:



./ping_scan.sh

[#27217] Tuesday, June 28, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
kilusy

Total Points: 171
Total Questions: 110
Total Answers: 128

Location: Cayman Islands
Member since Sat, Dec 5, 2020
3 Years ago
;