title: I want to use parallel-ssh to run a bash script on multiple servers, but it simple prints the echo statements
body: <p>I have a bash script called <code>sr_run_batch.sh</code> which does super resolution of images. Now I want to do testing on different servers in parallel at the same time. ie. 1 Virtual machine at one given point of time. then 2 virtual machines at one point of time , 3 and then 4.
  I tried writing into it the commands</p>
  
  <pre><code>for host in $(cat hosts.txt); do ssh "$host" "$command" &gt;"output.$host"; done 
  ssh-keygen &amp;&amp; for host in $(cat hosts.txt); do ssh-copy-id $host; done
  </code></pre>
  
  <p>where the file <code>hosts.txt</code> contains the list of servers: <code>username@ip</code>(format) but when I run this, it gives me substitution error</p>
  
  <p>Hence, I tried pssh (parallel-ssh)</p>
  
  <pre><code>pssh -h hosts-file -l username -P $command
  </code></pre>
  
  <p>command being <code>./sr_run_batch.sh</code></p>
  
  <p>but it didn't run, so I modified this to</p>
  
  <pre><code>pssh -h hosts-file -l ben -P -I&lt;./sr_run_batch.sh
  </code></pre>
  
  <p>But, for some unknown reason, it just prints the echo statements in the code.
  here is the code :</p>
  
  <pre><code>NList=(5)    
  VList=(1)    
  FList=("input/flower1.jpg" "input/flower2.jpg" "input/flower3.jpg" "input/flower4.jpg")    
  IList=("320X240"            "640X480"           "1280X960"          "1920X1200")    
  SList=(2 3)    
  for VM in ${VList[@]}; do
  
      for ((index=0; index &lt; ${#FList};)) do
          file=$FList[$index]
          image_size=$IList[$index]
          width=`echo $image_size|cut -d "X" -f1`
          height=`echo $image_size|cut -d "X" -f2`
          for scale_factor in ${SList[@]}; do
              for users in ${NList[@]}; do 
                  echo "V: $VM, " "F: $file, " "S: $scale_factor, " "I: $width $height , " "N: $users"
                  for i in `seq 1 $users` ; do
                      ./sr_run_once.sh $file $width $height $scale_factor &amp;
                  done
                  wait
              done # for users            
          done # for scale_factor
      done # for index
  done # for VM
  exit 0
  </code></pre>