SecureCRT自动备份脚本-华为

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SecureCRT自动备份脚本-华为相关的知识,希望对你有一定的参考价值。

# $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

 

以上是关于SecureCRT自动备份脚本-华为的主要内容,如果未能解决你的问题,请参考以下文章

利用SecureCRT实现网络设备自动备份-华为H3C篇

python多线程自动备份华为H3C交换机配置和LOG

SecureCRT自动备份-思科

网络设备(思科,华为交换机路由器)自动备份配置脚本

怎么使用SecureCRT自动登录华为交换机???

求教关于SecureCRT脚本问题:如何使用脚本判断telnet是不是成功,不成功跳过telnet下一台设备?