### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »

# Module: `core.magics.script`

Magic functions for running cells in various scripts.

## 1 Class

class `IPython.core.magics.script.``ScriptMagics`(shell=None)

  Bases: `IPython.core.magic.Magics`, `IPython.config.configurable.Configurable`

  Magics for talking to scripts

  This defines a base %%script 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.

  `__init__`(shell=None)
  `kill_bg_processes`()

    Kill all BG processes which are still running.

  `killbgscripts`(_nouse_='')

    Kill all BG processes started by %%script and its family.

  `shebang`(line, cell)

    %shebang [–proc PROC] [–bg] [–err ERR] [–out OUT]

    Run a cell via a shell command

    The %%script line is like the #! line of script, specifying a program (bash, perl, ruby, etc.) with which to run.

    The rest of the cell is run by that program.

    Examples

        In [1]: %%script bash
           ...: for i in 1 2 3; do
           ...:   echo $i
           ...: done
        1
        2
        3

    optional arguments:

      `--proc PROC` | The variable in which to store Popen instance. This is used only when –bg option is given.
      `--bg` | Whether to run the script in the background. If given, the only way to see the output of the command is with –out/err.
      `--err ERR` | The variable in which to store stderr from the script. If the script is backgrounded, this will be the stderr pipe, instead of the stderr text itself.
      `--out OUT` | The variable in which to store stdout from the script. If the script is backgrounded, this will be the stdout pipe, instead of the stderr text itself.

## 1 Function

`IPython.core.magics.script.``script_args`(f)

  single decorator for adding script args

### Navigation

- index
- modules |
- next |
- previous |
- home|
- search|
- documentation »
- The IPython API »