Welcome to the VanDyke Software Forums

Join the discussion today!


Go Back   VanDyke Software Forums > Scripting

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 12-09-2008, 11:43 PM
cyaron cyaron is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
Open 64 sessions using script

Hi,

I wish to perfrom the following,

Open 64 telnet connections (does CRT support it?, I have CRT v5.4), each on a sperate tab and run a script on each simuletany.

Is this possible?



I found the following script in the example page (see below).

How can I open a tab without a predefine session name (would like to add it in the script)?

How can I wrote to each tab?

Can I do it at the same time?



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

Sub Main()

' Prompt user for session paths to be used for connecting in tabs:
szSession1 = crt.Dialog.Prompt("Enter session 1:", "", "", False)
if szSession1 = "" then exit sub
szSession2 = crt.Dialog.Prompt("Enter session 2:", "", "", False)
if szSession2 = "" then exit sub
szSession3 = crt.Dialog.Prompt("Enter session 3:", "", "", False)
if szSession3 = "" then exit sub

' Get references to the tab objects for later use:
Set objTab1 = crt.Session.ConnectInTab("/S " & szSession1)
Set objTab2 = crt.Session.ConnectInTab("/S " & szSession2)
Set objTab3 = crt.Session.ConnectInTab("/S " & szSession3)

' Cycle through activation of each tab, waiting one second in between each
' activation:
objTab1.Activate
crt.Sleep 1000
objTab2.Activate
crt.Sleep 1000
objTab3.Activate
crt.Sleep 1000

End Sub


Thanks,

Yaron
Reply With Quote
  #2  
Old 12-10-2008, 02:08 PM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi Yaron,

The example script you provided should be a good starting place to accomplish what it is you are looking to do.

Specifically, you mentioned the following:

Quote:
Originally Posted by Yaron
How can I open a tab without a predefine session name (would like to add it in the script)?
As an example, an ad-hoc connection as you have described can be established using something similar to the following:

Code:
Set objTab1 = crt.Session.ConnectInTab("/SSH2 MyRemoteHost")
This would establish a connection in a new tab to the host 'MyRemoteHost' and retain a reference to that tab on the variable 'objTab1'.



Quote:
Originally Posted by Yaron
How can I wrote to each tab?
Now that you have a handle to at least the first tab, you could send data to the tab with a line of code similar to the following:

Code:
objTab1.Screen.Send "My Command To Send"
If you had references to multiple tabs (having already made connections in multiple tabs) in multiple variables such as objTab[1-9], you could send a command to those tabs as follows:

Code:
objTab1.Screen.Send "My Command To Send"
objTab2.Screen.Send "My Command To Send"
objTab3.Screen.Send "My Command To Send"
objTab4.Screen.Send "My Command To Send"

' ....

Using this information, are you able to develop your own scripting solution specific to your environment?
Reply With Quote
  #3  
Old 12-14-2008, 07:50 AM
cyaron cyaron is offline
Registered User
 
Join Date: Dec 2008
Posts: 2
Post Open 64 sessions using script

Thanks Kevin.

Two more issues:

1. Can I refer to variable in a loop? For example:

Do something like

For i = 0 to 63
Set objTab$i = crt.Session.ConnectInTab("/telnet 192.168.1.248 4016")
Next

For i = 0 to 63
objTab$i.Screen.Send
Next


2. Can the CRT perform the commands in parallel?


Thanks,

Yaron
Reply With Quote
  #4  
Old 12-15-2008, 10:57 AM
kbarnette kbarnette is offline
VanDyke Technical Support
 
Join Date: Aug 2007
Posts: 587
Hi Yaron,

Quote:
Originally Posted by cyaron
1. Can I refer to variable in a loop?
Unfortunately, vbscript does not support dynamic variable naming as you have described.

The easiest way to open all of your tabs and then send a command to each one would probably be as exemplified below:

Code:
For i = 0 to 63
    Set objCurrentTab = crt.Session.ConnectInTab("/telnet 192.168.1.248 4016")
    objCurrentTab.Screen.Send "MyCommand"
Next

Alternatively, it is conceivable that you could set up a collection of what would be 'Tab' objects, then iterate through each of the elements in your tab collection. While this method could end up being a tad messy, an example is below:

Code:
Dim colTabArray(4)

For i = 0 to 4
    Set colTabArray(i) = crt.Session.ConnectInTab("/telnet 192.168.1.248 4016")
Next


For each objTab in colTabArray
    objCurrentTab.Screen.Send "MyCommand"
    objCurrentTab.Screen.WaitForString "]$" ' Wait for our prompt
Next

Quote:
Originally Posted by cyaron
2. Can the CRT perform the commands in parallel?
Vbscript will execute each line in order, one after the other (with the exeption of subroutine or function calls).

Can you explain more about what you mean by 'perform the commands in parallel'?
Reply With Quote
  #5  
Old 10-12-2016, 05:51 AM
jakjok jakjok is offline
Registered User
 
Join Date: Sep 2016
Posts: 3
Hi Experts

i'm trying to do this , but what i can see that i can send commands only to first session , can you help me further on this

here is my code

Quote:
#$Language="VBScript"
#$Interface="1.0"

Dim vHosts(100)
vHosts(0) = "R1"
vHosts(1) = "ASA1"
vHosts(2) = "ASA2"

Dim z
z = 0
Dim colTabArray(4)

For i = 0 to 2
Set colTabArray(i) = crt.Session.ConnectInTab("/telnet [ip_redacted] 23")
Next


For each objTab in colTabArray

objTab.Screen.WaitForString "sername:"
objTab.Screen.Send "[redacted]" & VbCr
objTab.Screen.WaitForString "assword:"
objTab.Screen.Send "[redacted]" & VbCr
objTab.Screen.Send vHosts(z) & VbCr

objTab.Screen.WaitForString "sername:"
objTab.Screen.Send "[redacted]" & VbCr
objTab.Screen.WaitForString "assword:"
objTab.Screen.Send "[redacted]" & VbCr
objTab.Screen.Send VbCr
'objTab.Screen.Send "R1"
objTab.Screen.Send VbCr
objTab.Screen.Send VbCr
'objTab.Screen.WaitForString "]$" ' Wait for our prompt
z = z + 1
Next

thanks in advance..

Last edited by bgagnon; 10-12-2016 at 09:24 AM.
Reply With Quote
  #6  
Old 10-12-2016, 09:26 AM
bgagnon bgagnon is offline
VanDyke Technical Support
 
Join Date: Oct 2008
Posts: 4,207
Hi jakjok,

Please elaborate on what you are trying to accomplish.

You are only connecting to one host:

Quote:
Set colTabArray(i) = crt.Session.ConnectInTab("/telnet [ip_redacted] 23")
Do you intend to connect to the hosts in the vHosts() array instead?
__________________
Thanks,
--Brenda

VanDyke Software
Technical Support
support@vandyke.com
(505) 332-5730
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:59 PM.