本文主要内容转自:SecureCRT中python脚本编写学习指南
SecureCRT 支持 VB、JavaScript、Python 等多种脚本语言。
一、使用 python 语言实现 SecureCRT 中的 Dialog 功能
CodeBlock Loading...
二、使用 python 语言实现 SecureCRT 中的 Screen 功能
CodeBlock Loading...
三、实例
1. 实例一,循环运行命令
# $language = "python"
# $interface = "1.0"
# This automatically generated script may need to be
# edited in order to work correctly.
import time
start_time = time.time()
end_time = time.time()
def Main():
while True:
end_time = time.time()
crt.Screen.Synchronous = False
crt.Screen.Send("?")
crt.Screen.Send("\r\n")
crt.Screen.Send("\r\n")
time.sleep(1)
running_time = end_time - start_time
msg = "会话已断开\n" + \
"running ms : " + str(running_time) + "\n" + \
"start ms : " + str(start_time) + "\n" + \
"ent ms : " + str(end_time) + "\n"
crt.Dialog.MessageBox(msg,"session",64|2)
Main()
参考文献
- SecureCRT 中 python 脚本编写学习指南:https://www.cnblogs.com/zhaoyujiao/p/4908627.html
- 友情链接:http://www.cnblogs.com/OnOwnRoad/
- Python time sleep()方法:https://www.runoob.com/python/att-time-sleep.html
- Python(2)变量声明、变量类型:https://blog.csdn.net/qq20004604/article/details/78176329
- Python 日期和时间:https://www.runoob.com/python/python-date-time.html
- 可能是最全面的 python 字符串拼接总结:https://segmentfault.com/a/1190000015475309
- python 中整数,浮点数和字符串的转换:https://blog.csdn.net/mx_windforce/article/details/9009455
- python 毫秒级 sleep:https://www.cnblogs.com/mmix2009/p/3223188.html
- Python 获取以毫秒为单位的时间戳:https://www.jianshu.com/p/9a8bfc04dbac
- python 基础学习 04(死循环):https://blog.csdn.net/yujin2010good/article/details/51278706