title: Use of "here document" in for loop
body: <p>I need to wrap some code in the here document and run it with the ssh:</p>
  
  <pre><code>for service in ${services[@]}
  do
  ssh -tt root@${server} service=${service} 'bash -s' &lt;&lt; 'ENDSSH'
      ps axf | grep "service-${service}" | grep -v grep | awk '{print "kill -9 " $1}' | sh
      nohup java -jar service-${service}.jar &gt;&gt; nohup.out 2&gt;&amp;1 &amp;
  ENDSSH
  done
  </code></pre>
  
  <p>However the for loop can just do the first run and the ssh seems to catch the stdin and the <code>for</code> loop hangs there forever. How should I do to let the ssh return immediatly and continue the next for execution?</p>