Script illustrating the .get_output function (get_output.py)

Running this script displays the "Firmware name" line of the show version command.

#Required in all scripts for SLX:
from CLI import CLI

# Import the Python Regular Expressions (re) module:
import re

# Create Python objects:
slot_firmware = {}
cmd_show_ver = CLI("show ver", False)

# Using .get_output(), assign the result of show ver to a Python object named output:
output = cmd_show_ver.get_output()

for line in output:
    found = re.search(r'^(Firmware name:)\s+(\S+)$', line, re.M)
    if found:
        slot_firmware[found.group(1)] = found.group(2)

print("FIRMWARE:\n")
for key in slot_firmware:
    print("\t", key, "\t=> ", slot_firmware[key])

Run-log (get_output.py)

A log upon running get_output.py was as follows:

device# python get_output.py
FIRMWARE:

   Firmware name:  20.1.1_190404_0333