Network OS Administration Guide

Supporting Network OS 6.0.1a

Part Number: 53-1003768-04

Script illustrating the .get_output function (

The .get_output function returns—as a list—the output of the Network OS CLI commands assigned to a Python object.

Script (

This script displays a list of the following information:
  • Number of RBridges
  • World-wide name (WWN) addresses
  • IP addresses of the management interfaces
  • The VCS status
  • The fabric status
  • Device hostnames
Lines beginning with # are annotations.
#Required in all scripts for NOS:
from CLI import CLI

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

# Create Python objects:
rbridges = []
wwns = []
mgmt_ip_addresses = []
vcs_status = []
fabric_status = []
hostnames = []

# Runs show vcs, and assigns this NOS command to a Python object named cmd_show_vcs. 
# The optional "False" keyword suppresses stdout output: 
cmd_show_vcs = CLI("show vcs", False)

# As a list, assign the result of show vcs to a Python object named output:
output = cmd_show_vcs.get_output()

for line in output:
    found ='^(\d+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)$', line, re.M)

    if found:

print('rbridges: ', rbridges)
print('wwns: ', wwns)
print('mgmt_ip_addresses: ', mgmt_ip_addresses)
print('vcs_status: ', vcs_status)
print('fabric_status: ', fabric_status)
print('hostnames: ', hostnames)

Run-log (

A log upon running was as follows:

device# python
rbridges:  ['2']
wwns:  ['10:00:00:05:33:65:ED:F0']
mgmt_ip_addresses:  ['']
vcs_status:  ['Online']
fabric_status:  ['Online']
hostnames:  ['sw0']