SecureCRT自动备份脚本-华为

时间:2024-10-09 13:03:15
# $language = "VBScript"
# $interface = "1.0" Sub Main Const ForReading = 1, ForWriting = 2, ForAppending = 8
Dim fso,file1,line,str1,params
Set fso = CreateObject("Scripting.FileSystemObject")
Set file1 = fso.OpenTextFile("D:\SWbackup\list2.txt",Forreading, False)
crt.Screen.Synchronous = True
do while file1.AtEndOfStream <> True
'读取每一行
line = file1.ReadLine
'分割IP,用户名,密码
params = Split (line)
crt.session.LogFileName = "D:\SWbackup\log\" & params(0) & ".txt"
crt.session.Log(true)
'telnet登录
crt.Session.Connect "/TELNET " & params(0) '输入用户名
crt.screen.WaitForString "Username:",1
crt.screen.send params(1) & Chr(13) '输入密码
crt.Screen.WaitForString "Password:"
crt.Screen.Send params(2) & Chr(13)
'进入特权模式(enable)
crt.Screen.Send "system-view" & Chr(13)
crt.Screen.waitForString "]"
'执行dis cur命令
crt.Screen.Send "dis cur" & Chr(13)
crt.Screen.Send " "
crt.screen.send Chr(13)
crt.Screen.waitForString "return"
crt.Screen.waitForString "]"
crt.screen.send Chr(13)
'执行dis ip int b命令
crt.Screen.Send "dis ip int b" & Chr(13)
crt.Screen.Send " "
crt.screen.send Chr(13)
crt.Screen.waitForString "]"
'执行dis int b命令
crt.Screen.Send "dis int b" & Chr(13)
crt.Screen.Send " "
crt.screen.send Chr(13)
crt.Screen.waitForString "]"
crt.screen.send Chr(13)
'断开连接
crt.Session.Disconnect loop
crt.Screen.Synchronous = False End Sub