cpatte7372
asked on
VB Script Modification Request
Hello Experts,
I very clever Expert called Sedgwick help compile the script below.
At the moment if the following occurs changed state to down on a router the the script will run the following commands:
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
I would like to add another trigger like 'ospf neighbor down' to trigger another set of commands on the router like:
Dim g_vCommands(200)
g_vCommands(0) = "show ip eigrp"
g_vCommands(1) = "show ip dns"
g_vCommands(2) = "show ip dhcp server"
g_vCommands(3) = "show ip etc"
g_vCommands(4) = "show ip etc"
g_vCommands(5) = "show ip etc"
Basically, I would like different triggers to trigger a different set of commands.
As always, you're help is very much appreciated.
I very clever Expert called Sedgwick help compile the script below.
At the moment if the following occurs changed state to down on a router the the script will run the following commands:
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
I would like to add another trigger like 'ospf neighbor down' to trigger another set of commands on the router like:
Dim g_vCommands(200)
g_vCommands(0) = "show ip eigrp"
g_vCommands(1) = "show ip dns"
g_vCommands(2) = "show ip dhcp server"
g_vCommands(3) = "show ip etc"
g_vCommands(4) = "show ip etc"
g_vCommands(5) = "show ip etc"
Basically, I would like different triggers to trigger a different set of commands.
As always, you're help is very much appreciated.
# $language = "VBScript"
# $interface = "1.0"
' ASSUMPTION: file being 'tailed' contains information
' similar to:
' Jan 5 18:26:13 device01 9927: Jan 5 18:26:12: %LINK-3-UPDOWN: Interface POS5/2, changed state to down
' Jan 5 18:26:47 device02 6332: Jan 5 18:26:46.243: %LINK-3-UPDOWN: Interface GigabitEthernet3/1, changed state to down
' Jan 5 18:28:40 device01 9937: Jan 5 18:28:39: %LINK-3-UPDOWN: Interface POS5/2, changed state to down
Dim g_fso, g_shell
Set g_fso = CreateObject("Scripting.FileSystemObject")
Set g_shell = CreateObject("WScript.Shell")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim g_szLogFile, g_szFirstLogFilePath, objTab
g_szLogFile = GetMyDocumentsFolder & "\Command#__NUM___Results.txt"
Set objTab = crt.GetScriptTab
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
' .
' .
Sub Main()
	
' Make sure that we are running in Synchronous mode so
' that when WaitForStrings() finds something, we can
' capture the current line without risk of it already
' having flown by on the screen. This slows things down
' a bit, but provides insurance against errors due to
' SecureCRT and the script running asynchronously.
crt.Screen.Synchronous = true
' Start tailing a file...
crt.Screen.Send "tail tailfile.txt" & vbcr
' Example #1: Uses WaitForString to look for just the text
' we care about. Once the text is found, the
' line on which the text was located is captured
' and a piece of information is parsed using the
' Split() builtin VBScript method.
CaptureJustTheLinesWeCareAbout
' Example #2: Uses WaitForString to detect when every new line
' arrives from the remote. Each line of text is
' captured, and the Instr() builtin VBScript
' function is used to detect the presence of the
' specific text we care about. Iff it is present,
' the Split() builtin VBScript method is used to
' parse out the relevant piece of information.
'
' The benefit of this method over
' CaptureJustTheLinesWeCareAbout is that we
' can retrieve information from the line if
' the text we care about comes prior to the
' relevant piece of information that we would
' like to display as part of our notification.
'
' To enable this example, comment out the statement
' on line 29 and uncomment the line below:
' CaptureAllLinesAndSearchForTextWeCareAbout
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub CaptureJustTheLinesWeCareAbout()
MsgBox "Capturing just the lines we care about"
do
' Look for specific output
crt.Screen.WaitForString "changed state to down"
' Once specific output is found, capture the line
' of text on which the "changed to state down" string
' was located.
szCurrentLine = crt.Screen.Get(crt.Screen.CurrentRow, _
0, _
crt.Screen.CurrentRow, _
crt.Screen.Columns)
' Trim off any leading or training spaces
szCurrentLine = Trim(szCurrentLine)
' Use the Split() method (builtin VBScript method)
' to get at the component we care about (deviceID)
vElements = Split(szCurrentLine, " ")
for each x in vElements
'document.write(x & "<br />")
next
MsgBox "Device """ & vElements(3) & """ just went down."
	LogOutputOfSpecificCommandUseReadString
'MsgBox "Device """ & vElements(0) & vElements(1) & vElements(2) & vElements(3) & """ just went down."
'MsgBox "Device """ & vElements(0) & vElements(1) & vElements(2) & vElements(3) & "is " vElements(6)"
Loop
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub LogOutputOfSpecificCommandUseReadString()
' Instruct WaitForString and ReadString to ignore escape sequences when
' detecting and capturing data received from the remote (this doesn't
' affect the way the data is displayed to the screen, only how it is handled
' by the WaitForString, WaitForStrings, and ReadString methods associated
' with the Screen object.
objTab.Screen.IgnoreEscape = True
objTab.Screen.Synchronous = True
If Not objTab.Session.Connected then
crt.Dialog.MessageBox _
"Not Connected. Please connect before running this script."
exit sub
end if
Dim szCommand, szPrompt, nRow, szLogFileName, nIndex
' If this script is run as a login script, there will likely be data
' arriving from the remote system. This is one way of detecting when it's
' safe to start sending data. If this script isn't being run as a login
' script, then the worst it will do is seemingly pause for one second
' before determining what the prompt is.
' If you plan on supplying login information by waiting for username and
' password prompts within this script, do so right before this do..loop.
Do
bCursorMoved = objTab.Screen.WaitForCursor(1)
Loop until bCursorMoved = False
' Once the cursor has stopped moving for about a second, we'll
' assume it's safe to start interacting with the remote system.
' Get the shell prompt so that we can know what to look for when
' determining if the command is completed. Won't work if the prompt
' is dynamic (e.g. changes according to current working folder, etc)
nRow = objTab.Screen.CurrentRow
szPrompt = objTab.screen.Get(nRow, _
0, _
nRow, _
objTab.Screen.CurrentColumn - 1)
szPrompt = Trim(szPrompt)
Dim szLogFile
nIndex = 0
Do
szCommand = Trim(g_vCommands(nIndex))
' If the command is empty, then we should be done issuing commands
' (there's nothing else in our command array g_vCommands)
if szCommand = "" then Exit Do
' Set up the log file for this specific command
szLogFile = Replace(g_szLogFile, "__NUM__", NN(nIndex + 1, 2))
' Store the path for our first log file for later use (see end of this
' function...
if g_szFirstLogFilePath = "" then g_szFirstLogFilePath = szLogFile
' Send the command text to the remote
objTab.Screen.Send szCommand & vbcr
' Wait for the command to be echo'd back to us.
objTab.Screen.WaitForString vbcr, 1
objTab.Screen.WaitForString vblf, 1
Dim szResult
' Use the ReadString() method to get the text displayed while the
' command was runnning. Note that the ReadString usage shown below
' is not documented properly in SecureCRT help files included in
' SecureCRT versions prior to 6.0 Official. Note also that the
' ReadString() method captures escape sequences sent from the remote
' machine as well as displayed text. As mentioned earlier in comments
' above, if you want to suppress escape sequences from being captured,
' set the Screen.IgnoreEscape property = True.
szResult = objTab.Screen.ReadString(szPrompt)
Dim objFile
Set objFile = g_fso.OpenTextFile(szLogFile, ForWriting, True)
' If you don't want the command logged along with the results, comment
' out the very next line
objFile.WriteLine "Results of command: " & szCommand
' Write out the results of the command to our log file
objFile.WriteLine szResult
' Close the log file
objFile.Close
' Move on to the next command in our command array g_vCommands
nIndex = nIndex + 1
Loop
' Once we're complete, let's bring up Windows Explorer with the first of
' the log files selected.
g_shell.Run "explorer /e,/select,""" & g_szFirstLogFilePath & """"
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function GetMyDocumentsFolder()
Dim myShell
Set myShell = CreateObject("WScript.Shell")
GetMyDocumentsFolder = myShell.SpecialFolders("MyDocuments")
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function NN(nNumber, nDesiredDigits)
' Normalizes a single digit number to have nDesiredDigits 0s in front of it
Dim nIndex, nOffbyDigits, szResult
nOffbyDigits = nDesiredDigits - len(nNumber)
szResult = nNumber
For nIndex = 1 to nOffByDigits
szResult = "0" & szResult
Next
NN = szResult
End Function
If you only have two sets of commands, I would implement it this way. If you have multiple sets of commands, you should read a file of such commands and populate the dictionary from the file contents.
The If and For statements would replace your Do loop at line 161
Note: the Dim statement in the snippet below includes two of your script variables.
The If and For statements would replace your Do loop at line 161
Note: the Dim statement in the snippet below includes two of your script variables.
Dim dicCommands, szPrompt, szCommand
Set dicCommands = CreateObject("scripting.dictionary")
dicCommands.Add "changed state to down", "show ip int brief^show cdp neighbor^show run^show ip ospf^show ip bgp^show ip ospf neighbor^show int fas 0/0^show ldp neighbor^show run int tunn 0^show run int fas 0/1"
dicCommands.Add "ospf neighbor down", "show ip eigrp^show ip dns^show ip dhcp server^show ip etc^show ip etc^show ip etc"
'...
If dicCommands.exists(szPrompt) Then
For Each szCommand In Split(dicCommands(szPrompt), "^")
'do what you normally do with the command
Next
End If
ASKER
aikimark,
Thanks for responding. Unfortunately, I have limited scripting experience. I wouldn't have a clue where to include the amendments you made into the script.
Can you guide me please?
Cheers
Thanks for responding. Unfortunately, I have limited scripting experience. I wouldn't have a clue where to include the amendments you made into the script.
Can you guide me please?
Cheers
The For...Next structure replaces your Do...Loop structure at line 161
The other statements would normally appear somewhere before them, either in the general declarations area above Sub Main() or, for initialization statements, at the top of the Sub Main() routine.
The other statements would normally appear somewhere before them, either in the general declarations area above Sub Main() or, for initialization statements, at the top of the Sub Main() routine.
ASKER
aikimark,
going to give it a go now .... will let you know.
I hope it works
going to give it a go now .... will let you know.
I hope it works
ASKER
aikimark,
I totally don't know where to include the modifications into the script ... as I mentioned please understand my scripting abilities are seriously limited.
Cheer
I totally don't know where to include the modifications into the script ... as I mentioned please understand my scripting abilities are seriously limited.
Cheer
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
aikimark,
Thanks again for responding, I'm now getting the following error shown in the attachment
scripterror9.png
Thanks again for responding, I'm now getting the following error shown in the attachment
scripterror9.png
that should be an Exit For statement instead of an Exit Do statement
ASKER
aikimark, it didn't work.
None of the commands were run on the router.
All that happened was explorer opened up....
None of the commands were run on the router.
All that happened was explorer opened up....
were the commands issued in your original script?
ASKER
The original looked like this:
Thanks for your continued support
# $language = "VBScript"
# $interface = "1.0"
' ASSUMPTION: file being 'tailed' contains information
' similar to:
' Jan 5 18:26:13 device01 9927: Jan 5 18:26:12: %LINK-3-UPDOWN: Interface POS5/2, changed state to down
' Jan 5 18:26:47 device02 6332: Jan 5 18:26:46.243: %LINK-3-UPDOWN: Interface GigabitEthernet3/1, changed state to down
' Jan 5 18:28:40 device01 9937: Jan 5 18:28:39: %LINK-3-UPDOWN: Interface POS5/2, changed state to down
Dim g_fso, g_shell
Set g_fso = CreateObject("Scripting.FileSystemObject")
Set g_shell = CreateObject("WScript.Shell")
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
Dim g_szLogFile, g_szFirstLogFilePath, objTab
g_szLogFile = GetMyDocumentsFolder & "\Command#__NUM___Results.txt"
Set objTab = crt.GetScriptTab
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
'g_vCommands(1) = "ls -lR --color /tmp"
'g_vCommands(2) = "ps -eaf | grep vshelld"
'g_vCommands(3) = "tail -100 /var/log/messages"
'g_vCommands(4) = "sh run"
'g_vCommands(5) = ""
'g_vCommands(6) = ""
'g_vCommands(7) = ""
'g_vCommands(8) = ""
'g_vCommands(9) = ""
' .
' .
' .
Sub Main()
' Make sure that we are running in Synchronous mode so
' that when WaitForStrings() finds something, we can
' capture the current line without risk of it already
' having flown by on the screen. This slows things down
' a bit, but provides insurance against errors due to
' SecureCRT and the script running asynchronously.
crt.Screen.Synchronous = true
' Start tailing a file...
crt.Screen.Send "tail tailfile.txt" & vbcr
' Example #1: Uses WaitForString to look for just the text
' we care about. Once the text is found, the
' line on which the text was located is captured
' and a piece of information is parsed using the
' Split() builtin VBScript method.
CaptureJustTheLinesWeCareAbout
' Example #2: Uses WaitForString to detect when every new line
' arrives from the remote. Each line of text is
' captured, and the Instr() builtin VBScript
' function is used to detect the presence of the
' specific text we care about. Iff it is present,
' the Split() builtin VBScript method is used to
' parse out the relevant piece of information.
'
' The benefit of this method over
' CaptureJustTheLinesWeCareAbout is that we
' can retrieve information from the line if
' the text we care about comes prior to the
' relevant piece of information that we would
' like to display as part of our notification.
'
' To enable this example, comment out the statement
' on line 29 and uncomment the line below:
' CaptureAllLinesAndSearchForTextWeCareAbout
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub CaptureJustTheLinesWeCareAbout()
MsgBox "Capturing just the lines we care about"
do
' Look for specific output
crt.Screen.WaitForString "changed state to down"
' Once specific output is found, capture the line
' of text on which the "changed to state down" string
' was located.
szCurrentLine = crt.Screen.Get(crt.Screen.CurrentRow, _
0, _
crt.Screen.CurrentRow, _
crt.Screen.Columns)
' Trim off any leading or training spaces
szCurrentLine = Trim(szCurrentLine)
' Use the Split() method (builtin VBScript method)
' to get at the component we care about (deviceID)
vElements = Split(szCurrentLine, " ")
for each x in vElements
'document.write(x & "<br />")
next
MsgBox "Device """ & vElements(3) & """ just went down."
LogOutputOfSpecificCommandUseReadString
'MsgBox "Device """ & vElements(0) & vElements(1) & vElements(2) & vElements(3) & """ just went down."
'MsgBox "Device """ & vElements(0) & vElements(1) & vElements(2) & vElements(3) & "is " vElements(6)"
Loop
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Sub LogOutputOfSpecificCommandUseReadString()
' Instruct WaitForString and ReadString to ignore escape sequences when
' detecting and capturing data received from the remote (this doesn't
' affect the way the data is displayed to the screen, only how it is handled
' by the WaitForString, WaitForStrings, and ReadString methods associated
' with the Screen object.
objTab.Screen.IgnoreEscape = True
objTab.Screen.Synchronous = True
If Not objTab.Session.Connected then
crt.Dialog.MessageBox _
"Not Connected. Please connect before running this script."
exit sub
end if
Dim szCommand, szPrompt, nRow, szLogFileName, nIndex
' If this script is run as a login script, there will likely be data
' arriving from the remote system. This is one way of detecting when it's
' safe to start sending data. If this script isn't being run as a login
' script, then the worst it will do is seemingly pause for one second
' before determining what the prompt is.
' If you plan on supplying login information by waiting for username and
' password prompts within this script, do so right before this do..loop.
Do
bCursorMoved = objTab.Screen.WaitForCursor(1)
Loop until bCursorMoved = False
' Once the cursor has stopped moving for about a second, we'll
' assume it's safe to start interacting with the remote system.
' Get the shell prompt so that we can know what to look for when
' determining if the command is completed. Won't work if the prompt
' is dynamic (e.g. changes according to current working folder, etc)
nRow = objTab.Screen.CurrentRow
szPrompt = objTab.screen.Get(nRow, _
0, _
nRow, _
objTab.Screen.CurrentColumn - 1)
szPrompt = Trim(szPrompt)
Dim szLogFile
nIndex = 0
Do
szCommand = Trim(g_vCommands(nIndex))
' If the command is empty, then we should be done issuing commands
' (there's nothing else in our command array g_vCommands)
if szCommand = "" then Exit Do
' Set up the log file for this specific command
szLogFile = Replace(g_szLogFile, "__NUM__", NN(nIndex + 1, 2))
' Store the path for our first log file for later use (see end of this
' function...
if g_szFirstLogFilePath = "" then g_szFirstLogFilePath = szLogFile
' Send the command text to the remote
objTab.Screen.Send szCommand & vbcr
' Wait for the command to be echo'd back to us.
objTab.Screen.WaitForString vbcr, 1
objTab.Screen.WaitForString vblf, 1
Dim szResult
' Use the ReadString() method to get the text displayed while the
' command was runnning. Note that the ReadString usage shown below
' is not documented properly in SecureCRT help files included in
' SecureCRT versions prior to 6.0 Official. Note also that the
' ReadString() method captures escape sequences sent from the remote
' machine as well as displayed text. As mentioned earlier in comments
' above, if you want to suppress escape sequences from being captured,
' set the Screen.IgnoreEscape property = True.
szResult = objTab.Screen.ReadString(szPrompt)
Dim objFile
Set objFile = g_fso.OpenTextFile(szLogFile, ForWriting, True)
' If you don't want the command logged along with the results, comment
' out the very next line
objFile.WriteLine "Results of command: " & szCommand
' Write out the results of the command to our log file
objFile.WriteLine szResult
' Close the log file
objFile.Close
' Move on to the next command in our command array g_vCommands
nIndex = nIndex + 1
Loop
' Once we're complete, let's bring up Windows Explorer with the first of
' the log files selected.
g_shell.Run "explorer /e,/select,""" & g_szFirstLogFilePath & """"
End Sub
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function GetMyDocumentsFolder()
Dim myShell
Set myShell = CreateObject("WScript.Shell")
GetMyDocumentsFolder = myShell.SpecialFolders("MyDocuments")
End Function
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Function NN(nNumber, nDesiredDigits)
' Normalizes a single digit number to have nDesiredDigits 0s in front of it
Dim nIndex, nOffbyDigits, szResult
nOffbyDigits = nDesiredDigits - len(nNumber)
szResult = nNumber
For nIndex = 1 to nOffByDigits
szResult = "0" & szResult
Next
NN = szResult
End Function
Thanks for your continued support
I asked if the commands were issued in the original script. Did the original script actually work?
ASKER
No. The command weren't in the original script.
Why do you ask?
Why do you ask?
because I thought you were asking how to execute a different set of commands in addition to the set that you already had.
ASKER
To clarify the following commands weren't in the original script:
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
' .
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
' .
ASKER
Sorry for the confusion.
I wish to execute and different set of commands - not in addition to the set that is already there
I wish to execute and different set of commands - not in addition to the set that is already there
ASKER
The original might be confusing because both sets of commands look similar. However, I would like event changed state to down to activate the following commands
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
I would like to add another trigger like 'ospf neighbor down' to execute a different set of commands like:
Dim g_vCommands(200)
g_vCommands(0) = "show ip eigrp"
g_vCommands(1) = "show ip dns"
g_vCommands(2) = "show ip dhcp server"
g_vCommands(3) = "show ip etc"
g_vCommands(4) = "show ip etc"
g_vCommands(5) = "show ip etc"
Dim g_vCommands(100)
g_vCommands(0) = "show ip int brief"
g_vCommands(1) = "show cdp neighbor"
g_vCommands(2) = "show run"
g_vCommands(3) = "show ip ospf"
g_vCommands(4) = "show ip bgp"
g_vCommands(5) = "show ip ospf neighbor"
g_vCommands(6) = "show int fas 0/0"
g_vCommands(7) = "show ldp neighbor"
g_vCommands(8) = "show run int tunn 0"
g_vCommands(9) = "show run int fas 0/1"
' .
I would like to add another trigger like 'ospf neighbor down' to execute a different set of commands like:
Dim g_vCommands(200)
g_vCommands(0) = "show ip eigrp"
g_vCommands(1) = "show ip dns"
g_vCommands(2) = "show ip dhcp server"
g_vCommands(3) = "show ip etc"
g_vCommands(4) = "show ip etc"
g_vCommands(5) = "show ip etc"
Hopefully, someone will be able to test this on their system
ASKER
Hi aikimark,
Aren't you able to assist further?
I appreciate your help anyway, but if you could continue looking at it I would be very grateful.
Cheers
Aren't you able to assist further?
I appreciate your help anyway, but if you could continue looking at it I would be very grateful.
Cheers
I've done as much as I can. I do not have anything that looks like your system in order to test things.
ASKER
OK, thanks. Lets see if another Expert can pick it up...
Cheers mate
Cheers mate
You were already given the answer by aikimark, https://www.experts-exchange.com/questions/28162093/VB-Script-Modification-Request.html?anchorAnswerId=39262110#a39262110
You can read up on looping http://www.w3schools.com/vbscript/vbscript_looping.asp
Your answer here https://www.experts-exchange.com/questions/28162093/VB-Script-Modification-Request.html?anchorAnswerId=39262126#a39262126 should be more detailed then "it didn't work". It probably did but now you just have another error in another place.
Keep trouble shooting. Look at your error messages and follow them. If you are not sure what it is, look it up on http://www.w3schools.com/vbscript/default.asp or google it. A little frustration means your learning.
You can read up on looping http://www.w3schools.com/vbscript/vbscript_looping.asp
Your answer here https://www.experts-exchange.com/questions/28162093/VB-Script-Modification-Request.html?anchorAnswerId=39262126#a39262126 should be more detailed then "it didn't work". It probably did but now you just have another error in another place.
Keep trouble shooting. Look at your error messages and follow them. If you are not sure what it is, look it up on http://www.w3schools.com/vbscript/default.asp or google it. A little frustration means your learning.
@cpatte7372
A Google search (vbscript router commands) shows many hits. However, I can not advocate for one approach/solution over another, since I do not have a router with which I can test. Moreover, you lack the experience that would allow me to make a suggestion and then have you implement and test it in your environment. You need real hand-holding from someone that has sent commands to a router via VBScript. You probably need someone that can remote into your desktop to see what you are doing or make a site visit.
You lack the programming experience to even understand your script in its current state, much less make changes to it.
Please understand that routers are very important things to a business and that any codes you send to a router, either manually or through a script, can lock up, break, or open up a router -- all of which would be very bad for your business.
===============
If I had properly understood the true nature of your problem, I would not have commented. I only posted the best approach to supplying sequences of router commands, based on some string input (used as the name of the command sequence). I am still monitoring this question thread, but I'm ethically prevented from posting a suggestion that could hurt your company.
A Google search (vbscript router commands) shows many hits. However, I can not advocate for one approach/solution over another, since I do not have a router with which I can test. Moreover, you lack the experience that would allow me to make a suggestion and then have you implement and test it in your environment. You need real hand-holding from someone that has sent commands to a router via VBScript. You probably need someone that can remote into your desktop to see what you are doing or make a site visit.
You lack the programming experience to even understand your script in its current state, much less make changes to it.
Please understand that routers are very important things to a business and that any codes you send to a router, either manually or through a script, can lock up, break, or open up a router -- all of which would be very bad for your business.
===============
If I had properly understood the true nature of your problem, I would not have commented. I only posted the best approach to supplying sequences of router commands, based on some string input (used as the name of the command sequence). I am still monitoring this question thread, but I'm ethically prevented from posting a suggestion that could hurt your company.
I said virtually the same thing thing https://www.experts-exchange.com/questions/28163641/VB-Script-Modification-Request-Pt2.html?anchorAnswerId=39266565#a39266565
I can only look at the code and only help with the logic. I don't know enough about routers to go beyond that.
Two of us has suggested the same thing for you.
I can only look at the code and only help with the logic. I don't know enough about routers to go beyond that.
Two of us has suggested the same thing for you.
ASKER
With due respect, both you guys are wrong in your approach to this problem.
All I ask for the script to be modified so that one event triggers a separate set of commands.
The script does exactly what I would like it to do, but only for one event.
So, at the moment if an event called 'changed state to down' were to occur on a device a set of commands would be executed.
I just need another event to execute another set of commands.
The fact that this occurs on a router is immaterial.
If you can't help further I understand but I fear your comments have discouraged in any other Experts from helping.
Regards
All I ask for the script to be modified so that one event triggers a separate set of commands.
The script does exactly what I would like it to do, but only for one event.
So, at the moment if an event called 'changed state to down' were to occur on a device a set of commands would be executed.
I just need another event to execute another set of commands.
The fact that this occurs on a router is immaterial.
If you can't help further I understand but I fear your comments have discouraged in any other Experts from helping.
Regards
@cpatte7372
If your current script does not issue any commands, which I think you've told me in an earlier comment, I am unable to advise you on how to fix that problem. I have supplied code that DOES address multiple sets of commands, but I can not test your script in my environment.
If this script were issuing Net Use or IpConfig commands, I would be able to help you, since I can issue such commands in my environment. You want to send commands to a router, which is a very special part of the network.
If your current script does not issue any commands, which I think you've told me in an earlier comment, I am unable to advise you on how to fix that problem. I have supplied code that DOES address multiple sets of commands, but I can not test your script in my environment.
If this script were issuing Net Use or IpConfig commands, I would be able to help you, since I can issue such commands in my environment. You want to send commands to a router, which is a very special part of the network.
ASKER
aikimark
What does 'Neglected' question mean?
What does 'Neglected' question mean?
ASKER
aikimark,
Just so you're aware, the script is designed to respond to certain events. Following an event commands should be executed....
Cheers
Just so you're aware, the script is designed to respond to certain events. Following an event commands should be executed....
Cheers
ASKER
aikimark,
You're script doesn't send any of the commands to the screen/router
dicCommands.Add "changed state to down", "show ip int brief^show cdp neighbor^show run^show ip ospf^show ip bgp^show ip ospf neighbor^show int fas 0/0^show ldp neighbor^show run int tunn 0^show run int fas 0/1"
dicCommands.Add "ospf neighbor down", "show ip eigrp^show ip dns^show ip dhcp server^show ip etc^show ip etc^show ip etc"
You're script doesn't send any of the commands to the screen/router
dicCommands.Add "changed state to down", "show ip int brief^show cdp neighbor^show run^show ip ospf^show ip bgp^show ip ospf neighbor^show int fas 0/0^show ldp neighbor^show run int tunn 0^show run int fas 0/1"
dicCommands.Add "ospf neighbor down", "show ip eigrp^show ip dns^show ip dhcp server^show ip etc^show ip etc^show ip etc"
@cpatte7372
I know that my version of the script does not send any commands. My version of the script shows you how to package sets of commands that can be issued, based on some name you seem to be scraping from a terminal screen.
Neglected Question is a mechanism that sends email alerts to experts in the associated zones for a question.
I know that my version of the script does not send any commands. My version of the script shows you how to package sets of commands that can be issued, based on some name you seem to be scraping from a terminal screen.
Neglected Question is a mechanism that sends email alerts to experts in the associated zones for a question.
ASKER
Aikimark
Thanks for responding
I honestly don't see how your script shows me how to package sets of commands that can be issued?
Thanks for responding
I honestly don't see how your script shows me how to package sets of commands that can be issued?
Each .Add method of the dictionary object variable is a delimited string of commands. The first parameter of the method is the name of the command. I tried to use the string/name that you would gather from your earlier parsing.
A dictionary object is more flexible than the array object your code is currently using.
A dictionary object is more flexible than the array object your code is currently using.
ASKER
Cheers
ASKER