shift command?
Edgar Allen
era at sky.net
Tue Jun 19 23:47:42 CDT 2001
Forwarded message:
>
>I was planning on repeating this loop about 15 times for the machines on the
>LAN, as well as about 10 more for routers out on the frame. I had a thought
>(dangerous as it may be,) and was wondering if could specify multiple
>machine names to the variable the first time through as follows:
>
>BOX=box1 box2 box3 box4 ...
>
>and then use the shift command at the bottom of the code block somewhere,
>which would then start the loop using the next machine name? Is this even
>possible or am I way out there?
>
It seems like doing things the hard way to me.
Why build a loop using 'shift' to iterate across a list when
such a loop structure already exists ?
I reccommend using a 'for' loop instead.
>
>
>Psuedo code for the script is as follows.
#!/bin/bash
# Check for machines still reachable
delay=0
for mach in box1 box2 box{3,4,5,6,7,8}
do
ping -c 1 $mach
#check exit status of command
# Doing nothing if it is reachable is reasonable
if [ $? -ne 0 ] ; then
echo $mach is not responding
#mail all is not good
delay=300
fi
done
# Five minute delay if mail was sent, otherwise none
sleep $delay
# rerun the poll of all boxes
exec $0
More information about the Kclug
mailing list