How to Use Python Interactive Mode on Devices Running Junos OS
Different variants of Junos OS have different restrictions with respect to executing Python scripts on the device. The Junos OS with Enhanced Automation software image is a full-featured version of Junos OS that bundles additional automation tools with the image and disables Veriexec enforcement. On Junos OS variants that have Veriexec enforcement enabled, unsigned Python scripts must meet certain requirements before you can execute them on the device, and you can only execute the scripts using Python’s normal script mode in which scripts are run in the Python interpreter. By contrast, devices running Junos OS with Enhanced Automation, which are generally used in development environments, enable you to run unsigned Python scripts with fewer restrictions and also use Python interactive mode in the shell.
In addition, the Junos OS Evolved image runs natively on Linux, providing direct access to all the Linux utilities and operations, including Python and the Python libraries that are part of the base image. Thus devices running Junos OS Evolved enable you to run Python scripts and use Python in interactive mode in the Linux shell.
To invoke Python 2.7 or Python 3 in interactive mode in supported releases on Junos devices,
enter the python
or
python3
command, respectively, at
the shell prompt.
To start Python in interactive mode:
The Python interpreter is designated with the prompt >>>
at the beginning of a line or ...
to indicate
the continuation of a line.