zoukankan      html  css  js  c++  java
  • SecureCRT自动备份脚本-思科

    利用SecureCRT脚本对思科设备进行批量备份:

    (1)新建文本文件(注意保存路径,本次测试路径为D:ackuplist.txt):

      x.x.x.x username password enable_password   (#注:如果没有enable密码可以不写;每项用空格分割)

    (2)新建文本文件cisco.txt(路径D:ackupcisco.txt),内容如下:

    # $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:SWbackuplist.txt",Forreading, False)        
         crt.Screen.Synchronous = True
         do while file1.AtEndOfStream <> True        
            line = file1.ReadLine       
            params = Split (line)
            crt.session.LogFileName = "D:SWbackuplog" & 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 "enable" & Chr(13)
            crt.Screen.waitForString "#" 
        
            '执行sh run命令
            crt.Screen.Send "sh run" & Chr(13)
            crt.Screen.WaitForString " --More-- "
            crt.Screen.Send "                                           "
            crt.screen.send Chr(13)
            crt.Screen.waitForString "end" 
            crt.Screen.waitForString "#" 
            '执行sh ip int b命令 
            crt.Screen.Send "sh ip int b" & Chr(13)
            crt.Screen.Send "                        "
            crt.Screen.waitForString "#" 
            crt.screen.send Chr(13)
            '保存配置
            crt.Screen.Send "wr" & Chr(13)
            crt.Screen.waitForString "[OK]",8
            crt.Screen.waitForString "#" 
            crt.screen.send Chr(13)    
            '断开连接
            crt.Session.Disconnect         
           
            loop
            crt.Screen.Synchronous = False 
    End Sub

    (3)修改上面文本后缀个是为.vbs,即cisco.vbs;

    (4)运行CRT软件,菜单栏-->脚本-->执行-->找到脚本路径D:ackupcisco.vbs;

    (5)查看备份文件保存路径D:ackupconf。

     

  • 相关阅读:
    Go语言 插入排序并返回排序前的索引
    使用patch-package定制node_modules 中的依赖包
    移动端 rem自适应布局 (750的设计稿)
    通过原型截获input.value的方法
    ts 使用 keyof typeof
    logrotate日志管理工具
    【LeetCode刷题】239.滑动窗口最大值
    【LeetCode刷题】剑指Offer 48.最长不含重复字符的子字符串
    【LeetCode刷题】912. 排序数组
    【LeetCode刷题】744. 寻找比目标字母大的最小字母
  • 原文地址:https://www.cnblogs.com/ping-y/p/5825505.html
Copyright © 2011-2022 走看看