怎样使用SecureCRT录制自动脚本

Posted

tags:

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

参考技术A 输入登录的命令
  LANG=en_US.UTF-8
  su - username
  Password:
  结束录制
  Script -> Stop Recording Script
  把脚本存成你喜欢的名字,例如Script.vbs
  设置登录脚本
  选中会话,右键Properties -> Connection -> Logon Scripts:
  在“Logon scrip”前打钩,选中Scrip本回答被提问者采纳

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自动上传文件python脚本

SecureCRT自动化脚本

SecureCRT自动备份脚本-华为

SecureCrt VBS自动登录备份网络设备配置脚本

自动化脚本录制

自动化脚本录制并且自动化运行(po模型)