Network OS Administration Guide

Supporting Network OS 6.0.1a

Part Number: 53-1003768-04

Testing Python-script statements

While developing a Python script, you can test Network OS calls by entering them in the switch Python command shell. After the script is stable, you copy it to the switch and then test it further by running it from the command line.

  1. In privileged EXEC mode, enter the python command to access the Python shell.
    device# python
    Python 3.3.2 (default, Jun 5 2013, 11:04:06)
    [GCC 4.3.2] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>>
    Note that the device# prompt changed to a >>> Python prompt:
  2. Enter the script statements one at a time, verifying that they run as expected.
    >>> cmd_config_vlans = CLI('configure \n interface vlan 101-103 \n exit')
    !Command: configure \n interface vlan 101-103 \n exit
    !Time: Tue Jan  6 00:24:17 2015
    >>>
  3. Make corrections as needed.