December 1999
Beginner
528 pages
11h 10m
English
I wrote pingall quite a few years ago as part of a general reporting script that ran during the night. It pings all the hosts held in the hosts file.
The script cats the /etc/hosts file and greps out all lines that do not begin with a #.A while loop then reads in lines of filtered text. Awk is used to assign the first field of the filtered text to the variable ADDR. Using a for loop, each address is then pinged.
Here’s the script.
$ pg pingall
#!/bin/sh
# pingall
# grab /etc/hosts and ping each address
cat /etc/hosts| grep -v '^#' | while read LINE
do
ADDR=`awk '{print $1}'`
for MACHINE in $ADDR
do
ping -s -c1 $MACHINE
done
done The pingall script can easily expanded to include reporting functions of other network utilities. ...
Read now
Unlock full access