#16
|
||||
|
||||
Applying the script to what...
Hi Mike,
I would be using this script during unanticipated events. So, when I log in to the router, I will not be creating a log file. If the script can be modified to work with data pasted from the SecureCRT session buffer to the Windows Clipboard that would be great. Can't a script be run on the SecureCRT session buffer without having to paste it to the clipboard? Thanks, Greg |
#17
|
||||
|
||||
Hi chadack,
I've modified the previous script so that it uses the SecureCRT MENU_COPY to copy data to the clipboard, then copies the data into szSelection. crt.screen.sendspecial "MENU_COPY"Here's the complete example script. Code:
' Regular Expression Test ' 'Here is sample output from a T1 flapping - a script that could tell me how many seconds elapsed between the last controller X "down" and the last controller X "up" would be nice. In this case the controller X of interest is 0/1/0. ' Sample data: 'Jan 9 00:05:34 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/0/1, changed state to down (AIS detected) 'Jan 9 00:05:36 CST: %LINK-3-UPDOWN: Interface Serial0/0/1:0, changed state to down 'Jan 9 00:05:37 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/1:0, changed state to down 'Jan 9 00:05:43 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/0/1, changed state to up 'Jan 9 00:05:43 CST: %LINK-3-UPDOWN: Interface Serial0/0/1:0, changed state to up 'Jan 9 00:05:44 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/1:0, changed state to up 'Jan 9 00:52:56 CST: %CLEAR-5-COUNTERS: Clear counter on interface Serial0/0/1:0 by ... 'Jan 9 01:37:41 CST: %LINK-3-UPDOWN: Interface Serial1/3, changed state to down 'Jan 9 01:37:42 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/3, changed state to down 'Jan 9 01:39:32 CST: %LINK-3-UPDOWN: Interface Serial1/3, changed state to up 'Jan 9 01:39:35 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/3, changed state to up 'Jan 9 14:18:02 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/1/0, changed state to down (AIS detected) 'Jan 9 14:18:04 CST: %LINK-3-UPDOWN: Interface Serial0/1/0:0, changed state to down 'Jan 9 14:18:05 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0:0, changed state to down 'Jan 9 14:19:07 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/1/0, changed state to up 'Jan 9 14:19:08 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/1/0, changed state to down (RAI detected) 'Jan 9 14:19:19 CST: %CONTROLLER-5-UPDOWN: Controller T1 0/1/0, changed state to up 'Jan 9 14:19:21 CST: %LINK-3-UPDOWN: Interface Serial0/1/0:0, changed state to up 'Jan 9 14:19:24 CST: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/1/0:0, changed state to up CONST SM_DATE_TIME = 0 CONST SM_CONTROLLER_NUM = 1 CONST SM_CONNECT_TYPE = 2 CONST SM_CONTROLLER_STR = 3 CONST SM_UPDOWN_STR = 4 Dim re, Matches, Match Dim szController, szUpDown, szUp, szDown ' Warning: running this when not connected will fail because of "sendspecial" ' Put the selected text into the clipboard crt.screen.sendspecial "MENU_COPY" ' Extract the selected text from the clipboard into a variable as "Text" Set objIE = CreateObject("InternetExplorer.Application") objIE.Navigate "about:blank" szSelection = objIE.document.parentwindow.clipboardData.GetData("text") objIE.Quit Set re = New RegExp re.Global = TRUE re.MultiLine = TRUE re.IgnoreCase = TRUE re.pattern = "^([A-Za-z]{3} \d{1,2} \d{2}:\d{2}:\d{2}) [A-Z]{1,5}: \%CONTROLLER-(\d{1,5})-UPDOWN: Controller (\S+) (\S+), changed state to (down|up)" Set Matches = re.Execute(szSelection) szController = InputBox("Enter controller number to search for") 'msgbox Matches(0) For each Match in Matches 'MsgBox Match.Value & vblf & match.submatches(0) DateTime = Match.Submatches(SM_DATE_TIME) ControllerNum = Match.Submatches( SM_CONTROLLER_NUM ) ConnectionType = Match.Submatches( SM_CONNECT_TYPE ) ControllerStr = Match.Submatches( SM_CONTROLLER_STR ) szUpDown = Match.Submatches( SM_UPDOWN_STR ) If ControllerStr = szController Then If szUpDown = "up" Then szUp = Match Elseif szUpDown = "down" Then szDown = Match End If End If Next MsgBox "Date = " & DateTime & vbcr & _ "Controller# = " & ControllerNum & vbcr & _ "Connection Type = " & ConnectionType & vbcr & _ "Controller String = " & ControllerStr & vbcr & _ "Last Down = " & szDown & vbcr & _ "Last Up = " & szUp & vbcr
__________________
Mike VanDyke Software Technical Support [http://www.vandyke.com/support] |
![]() |
Thread Tools | |
Display Modes | |
|
|