Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is an old question, and Jason's answer works fine, but I would like to add this:</p> <pre><code>ssh user@host &lt;&lt;'ENDSSH' #commands to run on remote host ENDSSH </code></pre> <p>This can also be used with su and commands which require user input. (note the <code>'</code> escaped heredoc)</p> <p>Edit: Since this answer keeps getting bits of traffic, i would add even more info to this wonderful use of heredoc:</p> <p>You can nest commands with this syntax, and thats the only way nesting seems to work (in a sane way)</p> <pre><code>ssh user@host &lt;&lt;'ENDSSH' #commands to run on remote host ssh user@host2 &lt;&lt;'END2' # Another bunch of commands on another host wall &lt;&lt;'ENDWALL' Error: Out of cheese ENDWALL ftp ftp.secureftp-test.com &lt;&lt;'ENDFTP' test test ls ENDFTP END2 ENDSSH </code></pre> <p>You can actually have a conversation with some services like telnet, ftp, etc. But remember that heredoc just sends the stdin as text, it doesn't wait for response between lines</p> <p>Edit: I just found out that you can indent the insides if you use <code>&lt;&lt;-END</code> !</p> <pre><code>ssh user@host &lt;&lt;-'ENDSSH' #commands to run on remote host ssh user@host2 &lt;&lt;-'END2' # Another bunch of commands on another host wall &lt;&lt;-'ENDWALL' Error: Out of cheese ENDWALL ftp ftp.secureftp-test.com &lt;&lt;-'ENDFTP' test test ls ENDFTP END2 ENDSSH </code></pre> <p>(I think this should work)</p> <p>Also see <a href="http://tldp.org/LDP/abs/html/here-docs.html" rel="noreferrer">http://tldp.org/LDP/abs/html/here-docs.html</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload