From: alsontra@hotmail.com
Date: Sat Feb 07 2004 - 05:52:39 GMT-3
Hello Group,
After searching the archives for a SecureCRT terminal server
login script, I gave up and wrote a very simple one in Vbscript. The scripting
interface for CRT is actually quite refined. I'm only posting the one I wrote
as an example. Its almost worthless for those who simply need to setup simple
terminal connection. My intention is to drop complete configs on my rack
providers rack and avoid the trouble of reconfiguring every time I start a new
session. The example I am posting, is just that, an example. It demonstrates
one way to open 8 terminal session in Vbscript using SecureCRT. The second
script is specific to my rack provider, sorry...
# $language = "VBScript"
# $interface = "1.0"
crt.Screen.Synchronous = true
Sub Main
Dim prompt,RouterName,screenrow,result,i,problem,t,LoopCount,RouterNameMatch
LoopCount = "0"
t = 1
i = 1
RouterName=""
RouterNameMatch=""
problem ="0"
For i = 1 to 8
LoopCount = "0"
If i = 1 Then
RouterName = "SW1" '\routers host name for
host table on access server
RouterNameMatch="SW" '\first two characters
from the same routers login prompt
ElseIf i = 2 Then
RouterName = "R2"
RouterNameMatch= "R2"
ElseIf i = 3 Then
RouterName = "R3"
RouterNameMatch= "R3"
ElseIf i = 4 Then
RouterName = "R4"
RouterNameMatch= "R4"
ElseIf i = 5 Then
RouterName = "R5"
RouterNameMatch= "R5"
ElseIf i = 6 Then
RouterName = "R6"
RouterNameMatch= "R6"
ElseIf i = 7 Then
RouterName = "frs"
RouterNameMatch= "R7"
ElseIf i = 8 Then
RouterName = "R8"
RouterNameMatch= "R8"
Else
problem = "1" '\if there's a problem
this value is set and breaks the scripts loop
End If
crt.screen.send "telnet " & RouterName & Chr(13) '\telnet to router
Do While LoopCount < 6 '\added
repetition because some routers don't give a prompt on the first carriage
return
crt.screen.send vbCRLF
crt.Screen.WaitForString "any_string", 2 '\ pauses for 2 second
screenrow = crt.screen.CurrentRow
result = crt.Screen.Get(screenrow, 1, screenrow, 2 ) '\grabs first two 2
chars after the 1 row
If result = RouterNameMatch Then
crt.screen.Send Chr(30) & Chr(120)
Exit Do
ElseIf problem = "1" Then
Exit Do
Elseif LoopCount = 5 Then
i = 9
crt.screen.send "Error!"
Exit Do
Else
End If
LoopCount = LoopCount + 1
Loop
Next
crt.screen.synchronous = false
End Sub
OUTPUT FROM CRT++++++++++++++++++++++++++++++++++++++++++++++++++++++
ACP1#telnet SW1
Trying sw1 (1.1.1.1, 2001)... Open
SW1#
SW1#
ACP1#telnet R2
Trying R2 (1.1.1.1, 2002)... Open
R2#
R2#
ACP1#telnet R3
Trying R3 (1.1.1.1, 2003)... Open
R3#
R3#
ACP1#telnet R4
Trying R4 (1.1.1.1, 2004)... Open
R4#
R4#
ACP1#telnet R5
Trying R5 (1.1.1.1, 2005)... Open
R5#
R5#
ACP1#telnet R6
Trying R6 (1.1.1.1, 2006)... Open
R6#
R6#
ACP1#telnet frs
Trying frs (1.1.1.1, 2007)... Open
R7#
R7#
ACP1#telnet R8
Trying R8 (1.1.1.1, 2008)... Open
This archive was generated by hypermail 2.1.4 : Fri Mar 05 2004 - 07:13:47 GMT-3