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
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!