Solved

VBS Script Modification Pt2

Posted on 2012-03-10
5
564 Views
Last Modified: 2012-03-16
Hello Experts,

An expert helped compile the following text. However, when the commands are executed they are run one at a time, but I would like the commands to full complete before moving to another tab. I've already had help with a similar issue and all I would like is to have the similar issue applied to this situation.

So, the following is the script that I would like modified:

# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
   
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
   
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
    end if

    ' Find out what should be sent to all tabs
    szCommand = crt.Dialog.Prompt("Enter command to be sent to all tabs:", _
                                  "Send To All Connected Tabs", "ls", False)
    if szCommand = "" then exit sub
   
    If crt.Dialog.MessageBox(_
        "Are you sure you want to send the following command to " & _
        "__ALL__ tabs?" & vbcrlf & vbcrlf & szCommand, _
        "Send Command To All Tabs - Confirm", _
        vbyesno) <> vbyes then exit sub
   
    ' Connect to each tab in order from left to right, issue a command, and
    ' then disconnect...
    aryCmds = Split(szCommand, "|")

    For Each strOneCmd In aryCmds
        For nIndex = 1 to crt.GetTabCount
            Set objCurrentTab = crt.GetTab(nIndex)
            objCurrentTab.Activate
            if objCurrentTab.Session.Connected = True then
                crt.Sleep 500
                objCurrentTab.Screen.Send strOneCmd & vbcr
                crt.Sleep 1000
            end if
        Next
    Next
   
    MsgBox "The following command was sent to all connected tabs:" & vbcrlf & _
        vbcrlf & szCommand

End Sub
                 

The following is the script that I would like applied to the above. The expert that helped with the following script is called Shift-3 but I'm not sure if he's going to be available;


# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
   
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
   
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
    end if
   
    arrCommands = Array("term len 0", "show run", "show ip inte brief", "show cdp neigh",_
        "show spanning-tree summary", "show vlan-switch brief", "show spanning-tree brief",_
        "show spanning-tree uplinkfast", "show spanning-tree blockedports",_
        "show vtp status", "show interfaces trunk", "show standby brief", "show ip route",_
        "show ip ospf interface", "show ip ospf neigh", "show ip ospf",_
        "show ip ospf summary-address", "show ip ospf border-routers", "show ip bgp",_
        "show ip bgp summary", "show ip bgp neighbor", "show ip bgp vpnv4 all",_
        "show ip cef summary")

    ' Send commands to all tabs
    ' Connect to each tab in order from left to right, issue all commands, and
    ' then disconnect...
    For nIndex = 1 to crt.GetTabCount
        Set objCurrentTab = crt.GetTab(nIndex)
        objCurrentTab.Activate
            
        If objCurrentTab.Session.Connected = True Then
            For Each strCommand In arrCommands
                crt.Sleep 500
                objCurrentTab.Screen.Send strCommand & vbcr
                crt.Sleep 1000
            Next
        End If
    Next
End Sub
                                           

As you can see the script by shift-3 allows the commands to be fully completed before moving to the next tab. I would like that applied to the new script.

I hope that makes sense.

Cheers
0
Comment
Question by:cpatte7372
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 

Author Comment

by:cpatte7372
ID: 37704907
So Experts,

I think the section of the script I needed to be applied to the new script is the following:

' Send commands to all tabs
    ' Connect to each tab in order from left to right, issue all commands, and
    ' then disconnect...
    For nIndex = 1 to crt.GetTabCount
        Set objCurrentTab = crt.GetTab(nIndex)
        objCurrentTab.Activate
           
        If objCurrentTab.Session.Connected = True Then
            For Each strCommand In arrCommands
                crt.Sleep 500
                objCurrentTab.Screen.Send strCommand & vbcr
                crt.Sleep 1000
            Next
        End If
    Next
End Sub
                       

I think

Cheers
0
 

Author Comment

by:cpatte7372
ID: 37705020
I should also mention that script is be run an application called SecureCRT.

Cheers
0
 

Accepted Solution

by:
cpatte7372 earned 0 total points
ID: 37706619
As I haven't heard from any experts, I'm going to assume that its because I haven't explained myself well enough, as I'm sure there experts that can help me out here.

So, the script is used on and application called SecureCRT.

When the script run and I enter the commands, show a|show b|show c instead of executing all three commands in one shot the script will execute one after the other for each tab that I may have open. So if I have four tabs open in the applicaton the command once for each tab, however I would like it run all the commands in one show for each tab

I added a script that I thought might help an expert help me, but I still haven't had any response.


The script that needs modification is:

# $language = "VBScript"
# $interface = "1.0"
' SendToAll.vbs

Sub Main()
   
    if Not crt.Session.Connected then
        szSession = crt.Dialog.Prompt("Enter session:", "", "", False)
        if szSession = "" then exit sub
   
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
        crt.Session.ConnectInTab("/S " & szSession)
    end if

    ' Find out what should be sent to all tabs
    szCommand = crt.Dialog.Prompt("Enter command to be sent to all tabs:", _
                                  "Send To All Connected Tabs", "ls", False)
    if szCommand = "" then exit sub
   
    If crt.Dialog.MessageBox(_
        "Are you sure you want to send the following command to " & _
        "__ALL__ tabs?" & vbcrlf & vbcrlf & szCommand, _
        "Send Command To All Tabs - Confirm", _
        vbyesno) <> vbyes then exit sub
   
    ' Connect to each tab in order from left to right, issue a command, and
    ' then disconnect...
    aryCmds = Split(szCommand, "|")

    For Each strOneCmd In aryCmds
        For nIndex = 1 to crt.GetTabCount
            Set objCurrentTab = crt.GetTab(nIndex)
            objCurrentTab.Activate
            if objCurrentTab.Session.Connected = True then
                crt.Sleep 500
                objCurrentTab.Screen.Send strOneCmd & vbcr
                crt.Sleep 1000
            end if
        Next
    Next
   
    MsgBox "The following command was sent to all connected tabs:" & vbcrlf & _
        vbcrlf & szCommand

End Sub

Open in new window



Your help will be greatly appreciated....

Cheers

Carlton
0
 
LVL 42

Expert Comment

by:sedgwick
ID: 37706807
what is the error?
which line>?
0
 

Author Closing Comment

by:cpatte7372
ID: 37728551
I figured out the solution myself
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to refer to value 8 101
Android development question 2 109
collection output issue 9 92
killall tor  && service tor start  in Python 3 37
I hope you'll find this tutorial useful and interesting. So let's try to extend Tcl with a new package.  For anyone more deeply interested please check out the book "Practical Programming in Tcl and Tk". It's really one of the best written books abo…
The purpose of this article is to demonstrate how we can use conditional statements using Python.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question