in reply to Need advice on how to break foreach parsing loop into functions

If this is the output of a Cisco "show running-config" or "show startup-config", you might find it easier to have your script check the indentation. All the subcommands for an interface will be indented one space. The next command that isn't indented ends the stanza for that interface. For example, the description line for an interface will always match /^ description /.

It doesn't necessarily work with configurations that have been edited for input to the router, though. On input, the router checks tables with the names of all the legal commands and subcommands, so it doesn't need to look at the indentation or at the "!" that it inserts when displaying configurations.

  • Comment on Re: Need advice on how to break foreach parsing loop into functions
  • Download Code