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

Discussion in 'Python' started by Antgoodlife, Mar 5, 2012.

  1. Antgoodlife

    Antgoodlife Guest

    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
    format.

    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 :
    http://cpansearch.perl.org/src/MARKPF/Cisco-ShowIPRoute-Parser-1.02/Parser.pm
    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.
     
    Antgoodlife, Mar 5, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Harry
    Replies:
    3
    Views:
    385
    Joerg Jooss
    Oct 14, 2005
  2. chuck amadi
    Replies:
    1
    Views:
    494
    Larry Bates
    Jun 23, 2004
  3. Replies:
    19
    Views:
    1,146
    Daniel Vallstrom
    Mar 15, 2005
  4. SPJ
    Replies:
    4
    Views:
    907
    James Harris
    May 21, 2008
  5. 7stud --

    optparse: parse v. parse! ??

    7stud --, Feb 20, 2008, in forum: Ruby
    Replies:
    3
    Views:
    192
    7stud --
    Feb 20, 2008
Loading...

Share This Page