SecureCRT是VanDyke Software的一个商业SSH、Telnet客户端和虚拟终端软件 在SecureCRT中使用VBSCRIPT脚本,确实能够提高我们的工作效率,并且可以实现完全的自动化。

先看一个自动telnet登录的脚本例子:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# $language =  "VBScript"

# $interface =  "1.0"

Sub Main

crt.Screen.Synchronous  = True

' connect to host on port 23 (the default telnet port)

'

crt.Session.Connect "/TELNET login.myhost.com 23"

crt.Screen.WaitForString("login:", 5)

crt.Screen.Send "myusername"  &  chr(13)

crt.Screen.WaitForString("password:", 5)

crt.Screen.Send "mypassword"  &  chr(13)

crt.Sleep (1)

crt.Screen.Synchronous  = False

End Sub

PS:

  1. 如何发送控制字符(比如Ctrl+C) crt.screen.sendkeys(“^C”)