前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >python脚本来控制SecureCRT

python脚本来控制SecureCRT

作者头像
py3study
发布2020-01-08 10:52:36
2.1K0
发布2020-01-08 10:52:36
举报
文章被收录于专栏:python3python3

对于不熟悉VB语法的童鞋们,不妨使用python来操作CRT命令行。

如下代码:

代码语言:javascript
复制
#$language = "Python"
#$interface = "1.0"

def Main():
    tab = crt.GetScriptTab()

    if tab.Session.Connected != True:
        crt.Dialog.MessageBox(
            "Error.\n" +
            "This script was designed to be launched after a valid "+
            "connection is established.\n\n"+
            "Please connect to a remote machine before running this script.")
        return

    tab.Screen.Synchronous = True

    while True:
        tab.Screen.Send('\n')
        
        tab.Screen.WaitForStrings("Username:")
        tab.Screen.Send("admin" + '\n')
        
        tab.Screen.WaitForStrings("Password:")
        tab.Screen.Send("adc.admin" + '\n')
        
        tab.Screen.WaitForStrings("host>")
        tab.Screen.Send("enable" + '\n')
        
        tab.Screen.WaitForStrings("host#")
        tab.Screen.Send("copy tftp 192.168.10.110 bos_jx.bin ver" + '\n')
        
        tab.Screen.WaitForStrings("Install /mnt/boot/bcm.reset")
        tab.Screen.Send('\n')
        
        tab.Screen.WaitForStrings("host#")
        tab.Screen.Send("reboot" + '\n')
        
        tab.Screen.WaitForStrings('The system will be rebooted! Please enter "y/n"  to confirm:')
        tab.Screen.Send("y" + '\n')

#---------------------------main--------------------------------                    
Main()

更多精彩请参考官方文档: https://www.vandyke.com/support/securecrt/python_examples.html

本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-09-08 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档