maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   OS2008 / Maemo 4 / Chinook - Diablo (https://talk.maemo.org/forumdisplay.php?f=29)
-   -   bad for loop variable (https://talk.maemo.org/showthread.php?t=38233)

pulketo 2009-12-23 17:27

bad for loop variable [solved]
 
hello, busybox 'for' command is not working as it does on common distributions.

it says:
line 1: syntax error: Bad for loop variable
is there a special way to work with for variables in maemo??
my script run well on ubuntu

the for scripts is:
formpl:
for ((i=1;i<=$1;i++)) do mpl mp3 $i;done
mpl command works well ;)

thanks

Matan 2009-12-23 17:33

Re: bad for loop variable
 
This is not a bourne shell construct. If you want to use bash, install the bash package.

Or try something like for i in `seq 1 7` ; do ...

wnd 2009-12-29 00:05

Re: bad for loop variable
 
Backticks are obsolete, and problematic when nested. Modern Bourne shells, BusyBox included, undestand $()-notation.

Code:

for i in $(seq $n); do mpl mp3 $i;done
If $n is very large, then while-loop may be needed to avoid exceeding command line length limitation.

Code:

i=1
while test $i -le 100000; do
        mpl mp3 $i
        i=$(( $i + 1 ))
done


Sayantan 2010-07-16 10:16

Re: bad for loop variable
 
A solution::

#cat loop.sh
for ((i=1; i<=5; i++))
do
echo "welcome $i times"
done

# chmod 777 loop.sh
#./loop.sh


All times are GMT. The time now is 05:09.

vBulletin® Version 3.8.8