you can simply use the break command
it would go something like this:
if (communication is not working)
then (write to the log file AND break)
Quote:
The break command may optionally take a parameter. A plain break terminates only the innermost loop in which it is embedded, but a break N breaks out of N levels of loop.
Code:
#!/bin/bash
# break-levels.sh: Breaking out of loops.
# "break N" breaks out of N level loops.
for outerloop in 1 2 3 4 5
do
echo -n "Group $outerloop: "
for innerloop in 1 2 3 4 5
do
echo -n "$innerloop "
if [ "$innerloop" -eq 3 ]
then
break # Try break 2 to see what happens.
# ("Breaks" out of both inner and outer loops.)
fi
done
echo
done
echo
exit 0
|