Friday, October 8, 2010

Ah, a Breakthrough!

I have spent much of this past week working on the restore script, which purpose is to grab configurations from a text file and load them into the routers and switches, to save much time versus doing the process manually.  The good news is that the script works for the most part.  Sometimes however, a command entered on a router or switch will output a message which is preceded by a %.  These messages are good and are usually informative as well.  Unfortunately, when running an automated script to load configuration files into a device, these message cause the program to terminate.  Fortunately, the exact, specific nature of the problem (termination on any message beginning a %) makes it easy to fix.  I am exploring a couple different solutions at the time of this writing, and will pick the best one.

I'll write very briefly, too, about another issue I encountered, and solved, during the week, as it was interesting to me.  The interface I am using to send commands to the remote devices waits for a prompt to ensure that it is safe to send the command.  The prompt may look something like this, at it's most basic level:

Router#

or, perhaps,

Switch#

This is a most basic prompt encountered when configuring devices.  As increasingly complicated levels of configuration ensue, one may see increasingly complicated prompts.  For example, a prompt when configuring an interface on a certain device may look like:

Router(config-if)#

This is also a basic prompt which was matched and considered safe to send commands too.  In general, the interface accounted for any prompt with (config) in it.  Some prompts, however, do not have this (config) and thus were not considered a matching prompt.  The fix for this, was to simply alter the regular expression matching a prompt from 'config.*' (matching config followed by any text) to simply .* to match on any text that may appear there.

No comments:

Post a Comment