May 2017
Beginner
552 pages
28h 47m
English
The next example script will find the visible machines on the network using the ping command:
#!/bin/bash
#Filename: ping.sh
# Change base address 192.168.0 according to your network.
for ip in 192.168.0.{1..255} ;
do
ping $ip -c 2 &> /dev/null ;
if [ $? -eq 0 ];
then
echo $ip is alive
fi
done
The output resembles this:
$ ./ping.sh 192.168.0.1 is alive 192.168.0.90 is alive