<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Module: core.magics.script — IPython 2.3.0 documentation</title> <link rel="stylesheet" href="../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../', VERSION: '2.3.0', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../_static/jquery.js"></script> <script type="text/javascript" src="../../_static/underscore.js"></script> <script type="text/javascript" src="../../_static/doctools.js"></script> <link rel="top" title="IPython 2.3.0 documentation" href="../../index.html" /> <link rel="up" title="The IPython API" href="../index.html" /> <link rel="next" title="Module: core.oinspect" href="IPython.core.oinspect.html" /> <link rel="prev" title="Module: core.magics.pylab" href="IPython.core.magics.pylab.html" /> </head> <body> <div style="background-color: white; text-align: left; padding: 10px 10px 15px 15px"> <a href="http://ipython.org/"><img src="../../_static/logo.png" border="0" alt="IPython Documentation"/></a> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.oinspect.html" title="Module: core.oinspect" accesskey="N">next</a> |</li> <li class="right" > <a href="IPython.core.magics.pylab.html" title="Module: core.magics.pylab" accesskey="P">previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" accesskey="U">The IPython API</a> »</li> </ul> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../index.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Module: <tt class="docutils literal"><span class="pre">core.magics.script</span></tt></a><ul> <li><a class="reference internal" href="#class">1 Class</a></li> <li><a class="reference internal" href="#function">1 Function</a></li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="IPython.core.magics.pylab.html" title="previous chapter">Module: <tt class="docutils literal"><span class="pre">core.magics.pylab</span></tt></a></p> <h4>Next topic</h4> <p class="topless"><a href="IPython.core.oinspect.html" title="next chapter">Module: <tt class="docutils literal"><span class="pre">core.oinspect</span></tt></a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../_sources/api/generated/IPython.core.magics.script.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-IPython.core.magics.script"> <span id="module-core-magics-script"></span><h1>Module: <tt class="xref py py-mod docutils literal"><span class="pre">core.magics.script</span></tt><a class="headerlink" href="#module-IPython.core.magics.script" title="Permalink to this headline">¶</a></h1> <p>Magic functions for running cells in various scripts.</p> <div class="section" id="class"> <h2>1 Class<a class="headerlink" href="#class" title="Permalink to this headline">¶</a></h2> <dl class="class"> <dt id="IPython.core.magics.script.ScriptMagics"> <em class="property">class </em><tt class="descclassname">IPython.core.magics.script.</tt><tt class="descname">ScriptMagics</tt><big>(</big><em>shell=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.script.ScriptMagics" title="Permalink to this definition">¶</a></dt> <dd><p>Bases: <a class="reference internal" href="IPython.core.magic.html#IPython.core.magic.Magics" title="IPython.core.magic.Magics"><tt class="xref py py-class docutils literal"><span class="pre">IPython.core.magic.Magics</span></tt></a></p> <p>Magics for talking to scripts</p> <p>This defines a base <cite>%%script</cite> cell magic for running a cell with a program in a subprocess, and registers a few top-level magics that call %%script with common interpreters.</p> <dl class="method"> <dt id="IPython.core.magics.script.ScriptMagics.__init__"> <tt class="descname">__init__</tt><big>(</big><em>shell=None</em><big>)</big><a class="headerlink" href="#IPython.core.magics.script.ScriptMagics.__init__" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="method"> <dt id="IPython.core.magics.script.ScriptMagics.kill_bg_processes"> <tt class="descname">kill_bg_processes</tt><big>(</big><big>)</big><a class="headerlink" href="#IPython.core.magics.script.ScriptMagics.kill_bg_processes" title="Permalink to this definition">¶</a></dt> <dd><p>Kill all BG processes which are still running.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.magics.script.ScriptMagics.killbgscripts"> <tt class="descname">killbgscripts</tt><big>(</big><em>_nouse_=''</em><big>)</big><a class="headerlink" href="#IPython.core.magics.script.ScriptMagics.killbgscripts" title="Permalink to this definition">¶</a></dt> <dd><p>Kill all BG processes started by %%script and its family.</p> </dd></dl> <dl class="method"> <dt id="IPython.core.magics.script.ScriptMagics.shebang"> <tt class="descname">shebang</tt><big>(</big><em>line</em>, <em>cell</em><big>)</big><a class="headerlink" href="#IPython.core.magics.script.ScriptMagics.shebang" title="Permalink to this definition">¶</a></dt> <dd><div class="highlight-python"><div class="highlight"><pre>%shebang [--proc PROC] [--bg] [--err ERR] [--out OUT] </pre></div> </div> <p>Run a cell via a shell command</p> <p>The <cite>%%script</cite> line is like the #! line of script, specifying a program (bash, perl, ruby, etc.) with which to run.</p> <p>The rest of the cell is run by that program.</p> <p class="rubric">Examples</p> <div class="highlight-python"><div class="highlight"><pre>In [1]: %%script bash ...: for i in 1 2 3; do ...: echo $i ...: done 1 2 3 </pre></div> </div> <dl class="docutils"> <dt>optional arguments:</dt> <dd><table class="first last docutils option-list" frame="void" rules="none"> <col class="option" /> <col class="description" /> <tbody valign="top"> <tr><td class="option-group"> <kbd><span class="option">--proc <var>PROC</var></span></kbd></td> <td>The variable in which to store Popen instance. This is used only when –bg option is given.</td></tr> <tr><td class="option-group"> <kbd><span class="option">--bg</span></kbd></td> <td>Whether to run the script in the background. If given, the only way to see the output of the command is with –out/err.</td></tr> <tr><td class="option-group"> <kbd><span class="option">--err <var>ERR</var></span></kbd></td> <td>The variable in which to store stderr from the script. If the script is backgrounded, this will be the stderr <em>pipe</em>, instead of the stderr text itself.</td></tr> <tr><td class="option-group"> <kbd><span class="option">--out <var>OUT</var></span></kbd></td> <td>The variable in which to store stdout from the script. If the script is backgrounded, this will be the stdout <em>pipe</em>, instead of the stderr text itself.</td></tr> </tbody> </table> </dd> </dl> </dd></dl> </dd></dl> </div> <div class="section" id="function"> <h2>1 Function<a class="headerlink" href="#function" title="Permalink to this headline">¶</a></h2> <dl class="function"> <dt id="IPython.core.magics.script.script_args"> <tt class="descclassname">IPython.core.magics.script.</tt><tt class="descname">script_args</tt><big>(</big><em>f</em><big>)</big><a class="headerlink" href="#IPython.core.magics.script.script_args" title="Permalink to this definition">¶</a></dt> <dd><p>single decorator for adding script args</p> </dd></dl> </div> </div> </div> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="IPython.core.oinspect.html" title="Module: core.oinspect" >next</a> |</li> <li class="right" > <a href="IPython.core.magics.pylab.html" title="Module: core.magics.pylab" >previous</a> |</li> <li><a href="http://ipython.org">home</a>| </li> <li><a href="../../search.html">search</a>| </li> <li><a href="../../index.html">documentation </a> »</li> <li><a href="../index.html" >The IPython API</a> »</li> </ul> </div> <div class="footer"> © Copyright The IPython Development Team. Last updated on Jul 14, 2015. Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.2.3. </div> </body> </html>