EasyManuals Logo

Lantronix EMG 8500 User Manual

Lantronix EMG 8500
482 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #274 background imageLoading...
Page #274 background image
12: Scripts
EMGâ„¢ Edge Management Gateway User Guide 274
Python Custom Script - EMG CLI Session
An example of a Python Custom Script that uses the Pexpect module to interact with the CLI
session and the device ports to detect the prompt on any devices connected to the EMG, and set
the device port name to be the same as the device prompt:
#! python
# Script to detect the prompt on a device connected to an EMG device
port,
# and set the device port name to the prompt. Punctuation characters are
# removed and the device port number is appended to the name. Prompts
ending
# in '>' are detected. For example, for a Cisco device attached to device
# port 3 and displays this prompt:
# engcisco_cat3560>
# the name for device port 3 will be set to "engcisco_cat3560-3"
import pexpect
import datetime
import time
import sys
import re
now = datetime.datetime.now()
print("Detecting devices on EMG at ", end="")
print(now.strftime("%Y-%m-%d %H:%M"))
# start the CLI session to get number of device ports
p=pexpect.spawn('clisession -U sysadmin')
emgPrompt = ""
numPorts = 0
loggedIn = False
while not loggedIn:
i = p.expect([pexpect.TIMEOUT, pexpect.EOF,
'Model Number: SLC80(\d*)\r\n', 'Model Number:
SLB882\r\n',
'(\[.*>)'], timeout=10)
if i == 0: # Timeout
print("Timeout waiting to login.")
p.terminate(True)
sys.exit(1)
elif i == 1: # EOF
print("Session unexpectedly terminated.")
p.terminate(True)
sys.exit(1)
elif i == 2: # SLC8000 model number
model = p.match.group(1)
numPorts = int(model)
elif i == 3: # SLB882 model number
numPorts = 8
elif i == 4: # prompt

Table of Contents

Other manuals for Lantronix EMG 8500

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Lantronix EMG 8500 and is the answer not in the manual?

Lantronix EMG 8500 Specifications

General IconGeneral
BrandLantronix
ModelEMG 8500
CategoryGateway
LanguageEnglish

Related product manuals