Hi,
I'm having a problem with a while loop syntax that doesn't seem to loop correctly.
TODAY=`date +%d%m%Y`
while read hostname
#for hostname in $(cat $CONFIG)
do
OUTFILE=/tmp/health_check.$hostname.$TODAY
if [ ! -f $OUTFILE ]
then
touch $OUTFILE
func_header
else
rm $OUTFILE
func_header
fi
funcCheckIP # Calls a function
print
print " *** Automated Health Check on host $hostname completed *** "
print
print "** A summary of each checks have been written to a logfile."
print "** The logfile is located at $OUTFILE"
print "** Take note that the logfile does not contain any details of any errors"
done < $CONFIG
$CONFIG is a file (/tmp/hosts.name) where the contents are:
redang
tioman
sipadan
The wierd part is, when I played around by:
1) removing the calling function and replace it with a "print $hostname" all hosts are printed correctly.
2) replacing the while loop with "for hostname in $(cat $CONFIG)", all hosts are called properly.
Is there a limitation of a function calling another function and the number of loops allowed within the parent loop? Or am I making any sense at all? Any pointers are appreciated.