Just a quick clarification. Our routers use POSIX, not Bash. (You can enable it if you so choose, but it gets more messy). POSIX shell has issues with advanced loops like this... you probably want to use something like this:Try to run a simple loop script
Code:#!/bin/sh max=10 for (( i=2; i <= $max; ++i ))do echo"$i" done
but im getting "syntax error: bad for loop variable" when I run it. Wht am I doing wrong?
Thanks.
i=0
while [ $i -le 10 ]; do
echo "$i"
i=$(( i + 1 ))
done
Make sure you set the environment at the top:Thank you. I tried that and got this error:
loop: line 7: syntax error: unexpected end of file (expecting "do")
#!/bin/sh
i=0
while [ $i -le 10 ]; do
echo "$i"
i=$(( i + 1 ))
done
exit 0
Are you copying and pasting from a Windows notepad window by chance? Or some other intermediary source? I have heard of instances where additional hidden characters will mess with the script. Try copying it from here, and pasting it directly within nano (right-click on your mouse while in nano)... then save it. See if that helps?Not sure what i'm doing wrong
You previously omitted the first error message which gives the game away:thats strange. Its not working for me
View attachment 64399
View attachment 64400
Not sure what i'm doing wrong
: not foundne 2:
dos2unix loop.sh
Just to be clear, ASUS routers use BusyBox's implementation of the ash shell. You can see this by checking the "history" filename in the $HOME directory:Just a quick clarification. Our routers use POSIX, not Bash.
...
{
varStr1="Var1" varStr2="Var2"
if [[ "$varStr1" == "$varStr2" ]]
then echo TRUE
else echo FALSE
fi
}
{
varStr1="Var1" varStr2="Var2"
if [ "$varStr1" = "$varStr2" ]
then echo TRUE
else echo FALSE
fi
}
We use essential cookies to make this site work, and optional cookies to enhance your experience.