title: Execute FOR loop over ssh
body: <p>I am trying to execute this code on several Solaris 10 remote boxes over ssh. I am reading some connection information from the local file ipa.txt:</p>
  
  <pre><code>#!/bin/ksh
  
  while read hostn sid; do
  
     v_sid=$sid;
     ssh utest@$hostn &lt;&lt; EOF
  
     for D in $(df -k |grep ora | grep -i $v_sid | awk '{print $6}')
     do
         printf "$(df -h $D |tail -1|awk '{print "FS:", $6, " usage:", $5"%"}')\n"
     done
  
  EOF
  
  done &lt; ipa.txt
  </code></pre>
  
  <p>If I only execute the <strong>FOR</strong> loop directly into the terminal, it works. But If I put the whole script into a .ksh file and I execute that one, I receive the following error at line 3 (the line where is <strong>do</strong>, next line after FOR statement).</p>
  
  <pre><code>ksh[2]: syntax error at line 3 : `newline or ;' unexpected
  </code></pre>
  
  <p>There is a problem with the <strong>FOR</strong> loop but I don't understand where it is.</p>
  
  <p>Any suggestion?</p>
  
  <p>Thank you</p>