Why scripting will save you PT1

In a previous post I talked about documentation and planning for a change, but what can we do to really shorten the time it takes to implement and verify a change?

Scripting.

If we script things out ahead of time we don’t have to use our valuable time during a change window to type things out.  Plus we get to check, double-check, test, and debug all ahead of time to make sure things go how we want them to.

Here are a couple of scripts I’ve used lately to help me get info that I need quickly and format it so that it’s easier to look at.

1) Scripts in SecureCRT.

If you don’t own SecureCRT go buy it.  You can try to get everything done in putty, but a good terminal program will take you to a new level.

You can use several different scripting languages to help you out here.  You can do simple things like have it type commands for you, or complex things like read outputs and make decisions based on what comes out on the terminal.  It’s great for data entry type tasks that are horribly repetitive  but sill need to get done.

This is an example of a script I put together to go through and enter a show command for a list of vlans on a CatOS switch.  It’s sloppy from a code perspective, but it was fast and gets the job done.  (I’m working in VBScript in this case)
#$Language=”VBScript”
#$Interface=”1.0″
Sub Main
Dim counter
‘generic counter variable
Dim Arraysize
Dim RouterID
arr_VlanSet = Array(“1”, “2”, …keep listing your vlans here)
‘sloppy way to populate the vlanset…you can pull this from another file or whatever, but that’s more effort
‘than I wanted to put into this simple script
‘Creates a linear array for holding list of vlans
Arraysize = UBound(arr_VlanSet)
counter = MsgBox(Arraysize, vbOKOnly)
RouterID = “hostname of device goes here”
crt.Screen.Synchronous = True
For counter = 0 To Arraysize

crt.Screen.Send “show spantree ” & arr_vlanset(counter) & vbCr
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if
if crt.screen.WaitForString(“–More”, 1) then
crt.Screen.Send ” ”
end if

crt.Screen.Send ” ” & vbCr

crt.screen.WaitForString(RouterID)

Next
End Sub
Remember, these are supposed to save you time on the day, so you don’t need to be elegant in the code.  This goes through my list of vlans, put in the command, waits to see if a space needs to be entered (it does this 3 times) and then goes on to the next command.  If you have longer output than 3 screens it’ll wait for you to put in a keystroke manually instead of just going and missing a command.

 

More in PT2