How do I run a terminal command for different values How do I have to label i such that the do command is repeated for all values of i.

E.g. 

if i =2:
cd /Users/xxx/zTree; wine explorer /desktop=1,640x480 zleaf.exe /language english /name lab1
cd /Users/xxx/zTree; wine explorer /desktop=2,640x480 zleaf.exe /language english /name lab2


But somehow this does not work, where is my mistake?

display dialog "how many leafs?" default answer ""

set i to the text returned of result as integer
repeat while i &gt; 0
  tell application "Terminal"
    do script "cd /Users/xxx/zTree; wine explorer /desktop=$i,640x480 zleaf.exe /language english /name lab$i"
    set i to i - 1
    activate
  end tell
end repeat
medbot is right that you should really do this as a shell script but since it's hard to do dialog boxes like in Applescript here's the answer:

display dialog "how many leafs?" default answer ""

set i to the text returned of result as integer
repeat while i &gt; 0
    tell application "Terminal"
        do script "cd /Users/xxx/zTree; wine explorer /desktop=" &amp; i &amp; ",640x480 zleaf.exe /language english /name lab" &amp; i
    end tell
set i to i - 1
end repeat