Wednesday, October 17, 2007

PING.sh

#!/usr/bin/env bash
## Ping all machines in a Network
PING="$(which ping) -c 1 -W 1"
echo "Enter Subnet(eg:192.168.0)"
read Subnet
echo "Do you want to PING the entire network or a RANGE of IPs ? Enter your choice"
echo 1. Ping Entire Network
echo 2. Ping a RANGE
read choice

if [ $choice = 1 ];
then
{
echo Pinging.....
for((i=1;i<255;i++)); do
${PING} ${Subnet}.${i} > /dev/null 2> /dev/null
if [ $? -eq 0 ];
then
echo -e "${Subnet}.${i} is up"
fi
done
}
fi


if [ $choice = 2 ];
then
{
echo Enter the Starting IP of Range
read a
echo Enter the Last IP of Range
read b
echo Pinging.....
for((i=$a;i<$b;i++)); do
${PING} ${Subnet}.${i} > /dev/null 2> /dev/null
if [ $? -eq 0 ];
then
echo -e "${Subnet}.${i} is up"
fi
done
}
fi
exit 0

2 comments:

Unknown said...

I found Most of your posts very useful.

Just a different look of your script:-)


#!/bin/sh

PING="$(which ping) -c 1 -W 1"

echo -n "Enter Subnet(eg:192.168.0): "; read Subnet

while :
do
cat << !
1. Ping Entire Network
2. Ping a RANGE
3. Exit
!

echo -n "Your Choice?"
read choice

case $choice in
1).... ;;
2).... ;;
3) clear; exit ;;
*) echo; echo "\"$choice\" is not a valid option."; sleep 2 ;;
esac
done

//Jadu, http://unstableme.blogspot.com/

Anonymous said...

Thanks yaar

AT&T USA | Internet not working | Fix by custom APN

If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...