title: How do I place a heredoc at the end of a Bash sftp connection attempt?
body: <p>Trying to get this snippet working properly. I want to attempt an <code>SFTP</code> connection 3 times before breaking and exiting the shell. The catch is that there's a heredoc and <code>sftp</code> is not taking the heredoc as input when the connection is successful; the shell becomes interactive which I don't want.</p>
  
  <pre><code>count=0; until sftp -o StrictHostKeyChecking=no -i $key $server ; do ((count++)); [[ $count -eq 3 ]] &amp;&amp; echo $count &amp;&amp; break &amp;&amp; exit 64; done; &lt;&lt;END
  get docs/*
  quit
  END
  </code></pre>