I have a shell file with me in which I have a "while" loop that never stops:
I then have a file ping.txt with 4 ip in 4 lines and when I do a echo $NBS_LINE I have 4 lines
Code:
#!/bin/bash
FILE="/home/test/ping.txt"
NBS_LINE=`wc -l ping.txt | cut -d" " -f1`
i=1
while [ $i=$NBS_LINE ]
do
HOSTNAME=`head -n $i ping.txt | tail -n 1`
/bin/ping -c3 $HOSTNAME
if [ $? != 1 ]
then
echo "$HOSTNAME;YES"
else
echo "$HOSTNAME;NO"
fi
i=$(($i + 1))
done
but the problem is that when it reaches the last line does not stop. Have you an idea of the problem?
Bookmarks