title: for loop, expect and pssh
body: <p>I need a script to modify the same data in multiple servers. For now the for loop generate the command lines, but i'm experiencing some problems with expect and pssh.</p>
  
  <p>The for loop: </p>
  
  <pre><code>&lt;code&gt;
      for ((var1=1;var1&lt;=14; var1++))
      {
        cda stm add "$var1/$var2/$var3" ss 1
          for ((var2=1;var2&lt;=8;var2++))
          {
            cda stm add "$var1/$var2/$var3" ss 1
              for ((var3=1; var3&lt;64; var3++))
              {
                cda stm add "$var1/$var2/$var3" ss 1
              }
          }
      }
  &lt;/code&gt;
  </code></pre>
  
  <p>I'm using pssh instead ssh in expect script.</p>
  
  <p>The full code:</p>
  
  <pre><code>&lt;code&gt;
  
      #!/usr/bin/expect
  
      set timeout 20
  
      set ip [lindex $argv 0]
      set user [lindex $argv 1]
      set password [lindex $argv 2]
  
          for ((var1=1;var1&lt;=14; var1++))
  {
    cda stm add "$var1/$var2/$var3" ss 1
      for ((var2=1;var2&lt;=8;var2++))
      {
        cda stm add "$var1/$var2/$var3" ss 1
          for ((var3=1; var3&lt;64; var3++))
          {
            cda stm add "$var1/$var2/$var3" ss 1
          }
      }
  }        
      spawn pssh "$user\@$ip"
  
      expect "yes/no" {
              send "yes\r"
              expect "*?assword" { send "[lindex $argv 2]\r" }
              } "*?assword" { send "[lindex $argv 2]\r" }
              expect "SH"
  
      interact
  &lt;/code&gt;
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>&lt;code&gt;
  wrong # args: should be "for start test next command"
      while executing
  "for ((var1=1"
      (file "./ssh" line 9)
  &lt;/code&gt;
  </code></pre>