Reply
Thread Tools
Posts: 30 | Thanked: 4 times | Joined on Nov 2009
#1
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

Last edited by pulketo; 2010-01-08 at 16:44. Reason: solved
 
Posts: 1,224 | Thanked: 1,763 times | Joined on Jul 2007
#2
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 ...
 

The Following 2 Users Say Thank You to Matan For This Useful Post:
Posts: 99 | Thanked: 65 times | Joined on Jan 2008 @ Finland
#3
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
 
Posts: 1 | Thanked: 0 times | Joined on Jul 2010
#4
A solution::

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

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


 
Forum Jump


All times are GMT. The time now is 06:17.