title: How do I provide inline input to an IPython (notebook) shell command?
body: <p>I want to put together an IPython notebook with some shell commands and their input. In the bash prompt I can use "here-document" syntax:</p>
  
  <pre class="lang-bash prettyprint-override"><code>bash-3.2$ mysql -u root &lt;&lt;END_IPUT
  &gt; use mydb;
  &gt; show tables;
  &gt; END_INPUT
  </code></pre>
  
  <p>How do I get the same effect in IPython, and specifically in a jupyter notebook? I know how to execute shell commands as IPython as "line magics" or "cell
   magics", e.g.:</p>
  
  
  
  <pre class="lang-python prettyprint-override"><code>In [7]:  !! ls -tF
  Out[7]:  ['Demo-notebook.ipynb',
            'createdb.sql',
            ...
  </code></pre>
  
  <p>I've looked at <a href="http://ipython.readthedocs.io/en/stable/interactive/shell.html" rel="noreferrer">IPython as a system shell</a>, which shows how to enable some syntactic niceties. After the following, I can run system commands without prepending <code>!</code> or <code>!!</code> </p>
  
  <pre class="lang-python prettyprint-override"><code># Turn everything in $PATH into an alias; 
  # then enable calling aliases without ! or %
  %rehashx      
  %autocall 2 
  </code></pre>
  
  <p>But none of this helps with providing input to these commands inline: The here-document syntax is invalid in IPython, and results in a python <code>SyntaxError</code>. So how do I do it?</p>