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 02-05-2007, 01:34 PM
04NickySP2 04NickySP2 is offline
Registered User
 
Join Date: Feb 2007
Posts: 3
Opening new tabs and sending commands to them

Hello I'm currently trying to setup a script to help bring up multiple tabs for when I'm doing router installs. I'm using CRT 5.2.2

What I would like is to open up 6 tabs login to my jumpserver and then in each tab ssh out to key routers (1 in each window).

Currently I'm having trouble getting the command to run in the second window. It seems the commands work find but both commands run in the first tab.



# $language = "VBScript"
# $interface = "1.0"

Sub Main

crt.Screen.Synchronous = True

set newtab = crt.Session.ConnectInTab("/SSH2 /L username /PASSWORD mypasswd /C 3DES /M MD5 192.168.1.1")
'SSH to the jump server

crt.window.caption = "1st cisco router"

crt.Screen.Send "ssh username@ciscorouter1" & vbCr
'Tell the server to ssh to the actual router

crt.Screen.WaitForString "assword:"

crt.Screen.Send "ciscopasswd" & vbCr

crt.Screen.Send "enable" & vbCr

crt.Screen.WaitForString "assword:"

crt.Screen.Send "ciscoenablepasswd" & vbCr



' Open a new window to repeat the process for a 2nd cisco device

crt.Screen.Synchronous = True

set newtab = crt.Session.ConnectInTab("/SSH2 /L username /PASSWORD mypasswd /C 3DES /M MD5 192.168.1.1")
'SSH to the jump server

newtab.activate
'set the new tab to be the active one

crt.window.caption = "2nd cisco router"

crt.Screen.Send "ssh username@ciscorouter2" & vbCr
'Tell the server to ssh to the actual router

crt.Screen.WaitForString "assword:"

crt.Screen.Send "ciscopasswd" & vbCr

crt.Screen.Send "enable" & vbCr

crt.Screen.WaitForString "assword:"

crt.Screen.Send "ciscoenablepasswd" & vbCr

End Sub



Thanks in advance.
Reply With Quote
  #2  
Old 02-06-2007, 11:57 AM
jdev's Avatar
jdev jdev is offline
VanDyke Technical Support
 
Join Date: Nov 2003
Location: Albuquerque, NM
Posts: 1,093
Use the Tab object returned by the ConnectInTab() function

The crt.Screen object always applies to the first tab within an instance of SecureCRT/CRT.

To control tabs other than the first tab, get access to each individual tab object by using the newtab object (as you have it named) that is returned by the ConnectInTab() function you're calling. For example:

Code:
set newtab = crt.Session.ConnectInTab("/SSH2 /L username /PASSWORD mypasswd /C 3DES /M MD5 192.168.1.1")
'SSH to the jump server

' Since we now have a 'newtab' object, use 'newtab' everywhere we would normally use 'crt':
newtab.caption = "1st cisco router"

'Tell the server to ssh to the actual router:
newtab.Screen.Send "ssh username@ciscorouter1" & vbCr
newtab.Screen.WaitForString "assword:"
newtab.Screen.Send "ciscopasswd" & vbCr

...
Does this information help to answer your question and get you started in the right direction?

--Jake
__________________
Jake Devenport
VanDyke Software
Technical Support
YouTube Channel: https://www.youtube.com/vandykesoftware
Email: support@vandyke.com
Web: https://www.vandyke.com/support
Reply With Quote
  #3  
Old 02-09-2007, 10:00 AM
04NickySP2 04NickySP2 is offline
Registered User
 
Join Date: Feb 2007
Posts: 3
Yes that has been a great help.

Thanks!
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 05:50 PM.