#!/bin/bash
# Ping all the PC in a network segment
n=0
for (( i=1; i<255; i++ )) do ping -c1 -w1 $1.$i > /dev/null
if [ $? -eq 0 ]
then
echo "The $1.$i is Online"
n=$[$n+1]
else
:
fi
done
echo "There is $n user "
pi@bananapi ~/shell $ cat checkip.sh
#!/bin/bash
for ip in 192.168.0.{1..255}
do
ping $ip -c 2 &> /dev/null
if [ $? -eq 0 ];
then
echo $ip is alive
else
echo $ip is not connect
fi
done
pi@bananapi ~/shell $ cat checkip2.sh
#!/bin/bash
for ip in 192.168.0.{1..255}
do
(
ping $ip -c 2 &> /dev/null
if [ $? -eq 0 ];
then
echo $ip is alive
else
echo $ip is not connect
fi
)&
done
wait
pi@bananapi ~/shell $