作为网络工程师,SecureCrt是最常用的工具,而SecureCrt支持VBscript,使它变得非常强大,最近开始学习,尝试用VBS编一个自动备份设备配置的小程序。
先开启FTP server(10.127.30.74),再打开SecureCrt,运行下面的代码:
'用于自动备份思科配置
crt.Screen.Synchronous = True
Sub main
dim host(100)
'定义一个数组
host(0)='10.127.10.10'
'每行定义一个要备份的设备IP,有多少台设备,就写几行
host(1)='10.127.10.11'
host(2)='10.127.10.12'
host(3)='10.127.10.13'
host(4)='10.127.10.14'
For Each ip in host
If ip='' Then exit for
If crt.Session.Connected Then crt.Session.Disconnect
crt.Session.Connect ' /Telnet ' & ip
'ip即host值
crt.Screen.WaitForString 'Username: '
crt.Screen.Send 'xxx' & chr(13)
先开启FTP server(10.127.30.74),再打开SecureCrt,运行下面的代码:
'用于自动备份思科配置
crt.Screen.Synchronous = True
Sub main
dim host(100)
host(0)='10.127.10.10'
host(1)='10.127.10.11'
host(2)='10.127.10.12'
host(3)='10.127.10.13'
host(4)='10.127.10.14'
For Each ip in host
crt.Screen.WaitForString 'Username: '
crt.Screen.Send 'xxx' & chr(13)
