My sample script may well be using things that don't exist on a stock phone -- I've installed the BusyBox utilities on mine, so it has a lot of extra commands.

Just use this for a script:

#!/system/bin/sh
i=0