Sunday, February 6, 2011

Tips and Tricks: Saving Device Configs with Mac OS X Terminal

One of the age old techniques to save your device config is to simply issue a "sh run" (or equivalent on non-Cisco devices) and copy and paste the resulting output into a text file.  This method certainly works in the absence of at TFTP server, but it's kind of a pain and when you have a few devices it becomes time consuming in a hurry.

In a Windows environment I use PuTTY.  PuTTY has a built in feature that allows you to save the terminal session you're working on.   At home I have a Mac.  To that end, here's how I save configs if there isn't a TFTP server available.

I haven't bothered looking for a good full featured alternative to the standard built in OS X Terminal.app, and since I have a heavy Linux background I'm actually quite at home with it.  So how can we save configs without having to copy and paste them manually into a blank text file?  By saving the terminal buffer!

First, for speed's sake, I always disable paging so that you don't get the "--More--" prompts.

        terminal length 0


Now, since the terminal buffer is most likely full of a whole bunch of other stiff that we don't care about, clear out the whole buffer with a ⌘-k (or View --> Clear Scrollback from the Menu bar).  Now give it the ole:


        sh run


You'll see the entire config fly by without stopping.  When it's done simply save the contents of the buffer (which is now only your sh run) with a ⌘-s (you'll be prompted with a save dialogue to give it a name and select the location) and you're done!  

If you're going to keep working then you may want to turn paging back on, or you may miss longer output.  The default is 24 lines.


        terminal length 24


 HTH!

2 comments:

  1. Good tip. I'm not trying to be s smart ass but since I discovered Kiwi CatTools I don't save configs much any more unless I need to copy something for support purposes... just change away knowing that at midnight everything gets grabbed and archived and an e-mail goes to my helpdesk queue so others on my team can see if / what might have been changed. I was used to manually maintaining a library of TFTPd files and I thought I might be wasting my time as I set up CatTools but after about a year now I'm sold.

    ReplyDelete
  2. Agreed. A proper configuration management tool is far better for a production network than using something like this. I only use this during my own labbing if a TFTP server isn't available.

    Although I've never used CatTools personally I have heard good things about it from a few places. One of these days I'll get around to trying it out.

    ReplyDelete