Getting clean output from Extreme switch CLI using Python
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎10-06-2017 02:35 PM
I am writing a python script to run some show commands on Extreme switches and storing output in a variable. I am able to accomplish that but the output is not as I would like. I am seeing the command and also switch name in my output but I would like to just see the result of my show command and nothing else.
This is what I am seeing:
print "ISC Port is: ", ISC
ISC Port is: sh vlan ISC | i Tag:
Tag: 1:1g
Ext-SW1.com.5 #
This is what I would like to see:
ISC Port is: Tag: 1:1g
Here is my code where I am reading output:
ISC = "sh vlan ISC | i Tag:"
tn.write(ISC + "\n")
idx, obj, output = tn.expect(["\.\r\n\r\*"], int(timeout))
print "ISC Port is: ", outputHow do I get rid of device name and my commands from output to show only output. I played around with "read_until" but can't seem to get it cleaned up. Example:
tn.write(ISC + "\n")
tn.read_until(".2 #")
idx, obj, output = tn.expect(["\.\r\n\r\*"], int(timeout))
print "ISC Port is: ", outputAny help will be appropriated.
This is what I am seeing:
print "ISC Port is: ", ISC
ISC Port is: sh vlan ISC | i Tag:
Tag: 1:1g
Ext-SW1.com.5 #
This is what I would like to see:
ISC Port is: Tag: 1:1g
Here is my code where I am reading output:
ISC = "sh vlan ISC | i Tag:"
tn.write(ISC + "\n")
idx, obj, output = tn.expect(["\.\r\n\r\*"], int(timeout))
print "ISC Port is: ", outputHow do I get rid of device name and my commands from output to show only output. I played around with "read_until" but can't seem to get it cleaned up. Example:
tn.write(ISC + "\n")
tn.read_until(".2 #")
idx, obj, output = tn.expect(["\.\r\n\r\*"], int(timeout))
print "ISC Port is: ", outputAny help will be appropriated.
7 REPLIES 7
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎10-09-2017 12:21 PM
No, we are running 15.x.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎10-08-2017 08:18 AM
As Dave mentionned, if you are running 21 or later, you really should consider JSONRPC.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
‎10-06-2017 02:47 PM
If the switch is running EXOS 21.x or later, you could use JSONRPC instead of screen scraping the telnet display. An example script is here: https://github.com/extremenetworks/ExtremeScripting/tree/master/EXOS/Python/jsoncli
