SecureCRT python 脚本
记录编写CRT的python脚本遇到的问题
向CRT的脚本传递参数的两种方式
一种是命令行的方式
/path/CRT.exe <filename>.py /ARG arguments //这样就会将参数argument传递给脚本
二种是按钮方式
创建按钮时,指定要执行的脚本,和填入需要传递的
接受脚本传递的参数,crt.Arguments [0]而不是crt.Arguments(0)
写成crt.Argument(0)执行脚本时会报错:TypeError Error:'SecureCRT.Arguments' object is not callable
python脚本中crt.Screen.WaitForStrings的使用
crt.Screen.WaitForStrings()用来获取屏幕输出的字符串,可以选择在指定时间内等待多个字符串的出现
python脚本上该函数和js/vb脚本使用上有点不同,由python语言的特性决定
正确用法时crt.Screen.WaitForStrings(["string0","string1",timeout]),timeout)指的是指定时间内
当出现string0字符串时,该函数返回1,当出现string1时,返回2,超时,返回0
错误用法crt.Screen.WaitForStrings("string0","string1",timeout),执行时,会提示TypeError Error:an integer is required
原因:
In Python, [ ]s are required to designate what strings you would like WaitForStrings to well, wait for. The first argument must either be a single string, or an array of multiple strings. The second argument must be an integer representing the timeout value.