I'll kill myself for not knowing this but... I wanna create a loop based on the outcome of a query (wl assoclist) that just runs code if it's negative (= "") and if not, sleeps then re-runs the loop. so far I have a very simple 1 line command that does the first part:
Code:
#!/bin/sh
if [ "`/usr/sbin/wl -i wl0.1 assoclist`" = "" ]; then
/usr/bin/killall chilli && /usr/sbin/chilli --conf /jffs/chilli.conf;
fi
and the only way i can think of doing the second bit is expanding it to about 20 lines with a separate function and increasing a counter. which just sounds too much to be the best way of doing it. any tips?
thanks.
edit: oh hangon...
Code:
#!/bin/sh
KILLCHILLI=0
while ($KILLCHILLI == 0) {
if [ "`/usr/sbin/wl -i wl0.1 assoclist`" = "" ]
then
/usr/bin/killall chilli && /usr/sbin/chilli --conf /jffs/chilli.conf
$KILLCHILLI = 1
else
sleep 600
fi
}
edit: argghh...
Code:
#!/bin/sh
KILLCHILLI=0
while ($KILLCHILLI == 0)
do
if [ "`/usr/sbin/wl -i wl0.1 assoclist`" = "" ]; then
echo "$KILLCHILLI"
KILLCHILLI=1
echo "end loop"
else
sleep 60
fi
done
/tmp # /tmp/killchilli2
/tmp/killchilli2: /tmp/killchilli2: 14: 0: not found
EDIT: took me half a day but finally got there, and i know i should prolly do a do while instead of while do but i'm not spending another 6 hours over it
Code:
#!/bin/sh
KILLCHILLI=0
KILLEND=4
while [ $KILLCHILLI != $KILLEND ]
do
if [ "`/usr/sbin/wl -i wl0.1 assoclist`" = "" ]; then
KILLCHILLI=$KILLEND
/usr/bin/killall chilli && sleep 5 & /usr/sbin/chilli --conf /jffs/chilli.conf
else
KILLCHILLI=`expr $KILLCHILLI + 1`
if [ $KILLCHILLI == $KILLEND ]; then
break
else
sleep 480
fi
fi
done