Ping is a good tool to easily check or troubleshoot a system whether it is online or not.
Provided the system or device is allowed to reply to any
ICMP request.
A simple Bash script below shows how to ping a Class C
subnet. Replace the IP Address range below if you want to use it depending on the IP Address set on your network.
It also illustrates how to make use of while loop, increment
a variable counter, and use a variable to substitute as part of the whole
command in Bash.
#!/bin/sh
i=0
while [ $i -ne
255 ] # initialize the counter don't
exit until 255 counter is reached
do
i=$(($i+1)) #increment the variable counter by adding 1
to it
echo "$i" # just show the counter as it is
incremented
ping -c2 192.168.0.$i # ping the IP Address twice $i will be
substituted with the current number in the loop
done
That's it, it will ping the IP Address twice. If the result
shows 100% packet loss then the system could be offline or not allowed to reply
to ICMP request.
However, if the reply shows 64 bytes from IP.Address then
the system is online.
The script can be expanded to send an email if the IP
Address if offline or just log the reply of the IP Address to be reviewed later
on.
Till next time. Stay safe! and keep things up!
Do ASAP, Always Say A Prayer...
================================
Free Android Apps:
Click links below to find out more:
Free Android Apps:
Click links below to find out more:
Excel Keyboard guide:
https://play.google.com/store/apps/details?id=chrisjoms.myexcelapplicationguide
Heaven's Dew Fall Prayer app for Android :
https://play.google.com/store/apps/details?id=soulrefresh.beautiful.prayer
Catholic Rosary Guide for Android:
Pray the Rosary every day, countless blessings will be showered upon your life if you recite the Rosary faithfully.
https://play.google.com/store/apps/details?id=com.myrosaryapp
Divine Mercy Chaplet Guide (A Powerful prayer) BFF = Be Filled Faith:
Comments
Post a Comment