Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Parse cisco's "show ip route" output in Python 2.7

Thread Tools

Parse cisco's "show ip route" output in Python 2.7

Posts: n/a
Hi All,

Long time reader, first time poster. I'm trying to parse the output
of the SHOW IP ROUTE command from a cisco router (It's a 3800 Series
IOS 12.4 although almost all should have same output format) and put
it into a CSV format to import into a database or spreadsheet.
While we of course have Static / Connected routes, we also have lots
of dynamic routing coming in via OSPF, BGP, RIP, etc...

The output of the command is easy enough for me to get into text files
via parimiko (on that, does this module or equivalent work on Python 3
yet?) .. it's just tough to present the data into a csv or tabbed

To me, although I've done similar things in the past, it's a fairly
brutal output format to parse up. I was about to post some sample
input, but I am even having a hard time sanitizing the IP's for use on
this forum (Any utility for that?) as it's filled with IP addresses
that I cannot share. I'd love some python module if anyone has an
idea where I can get it?

Perl does seem to have something similar :
however, I'd like to keep it in python...

Mainly, did someone already do this so I don't have to reinvent this
wheel (which probably won't roll straight)?

Thanks in advance, and hopefully I've given enough information.. I've
been trying to parse it for about 9 hours... but the script get's
worse and worse as I keep finding flaws in my logic.
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
optparse: parse v. parse! ?? 7stud -- Ruby 3 02-20-2008 05:20 AM
How to parse the os.system() output in python Python 5 03-18-2007 05:08 AM
How to parse a string like C program parse the command line string? C Programming 19 03-15-2005 07:41 PM
parse output screen ok but cant get desired output new file! chuck amadi Python 1 06-23-2004 02:16 PM
Parse Text File and Output to File John M. Lembo Perl 0 08-01-2003 04:34 PM