VantageManager Telnet 脚本命令
脚本版本 1.1,2019-04-20
脚本由若干行组成,这些行将按顺序执行。
任何空行或以分号 ";" 开头的行将被忽略。
可能为:
- 用单引号 ' 或双引号 " 包裹的常量字符串。可插入特殊字符,如 \n \t 等。示例:"show ver"
- 先前已赋值的变量标识符(参见下文 set 命令)
- 两个 由+运算符分隔。示例:"abcd" + "def"
- 如下定义的命令/函数的结果。示例:"结果是:" + recuntil " >"
- 先前已赋值的变量标识符(参见下文set命令)
可能为:
- 常量整数。例如 1, 5。
- 先前已赋值的变量标识符(参见下文的 set 命令)
- 两个 - 由+运算符分隔的表达式。示例:3+7
- 包含"not"、"and"、"or"运算符的布尔表达式。结果示例:not 2 [0],3 and 4 [1]
- 可使用括号。示例:(3 and 0) or 11 [1]
- 使用==或!=运算符比较两个整数或字符串的结果。示例:"aa"==recuntil " >", 2!=5
- 下文定义的命令/函数执行结果。示例:match "def", "abcdef" [1]
命令/函数:
send
通过telnet向被测设备发送字符串
返回与发送内容相同的字符串。
sendln
通过telnet向被测设备发送字符串后跟换行符(CRLF)
返回与发送内容相同的字符串。
recuntil
从被测设备接收数据直至包含指定字符串
返回接收到的数据,包含该字符串但不包含该字符串。
recln
从被测设备接收数据直至下一个换行符
返回接收到的数据,包含该换行符但不包含该换行符。
wait
等待指定秒数
返回 1
failif
如果出现错误,将中止脚本执行(同时中止测试执行)并显示错误信息。 不为 0。
如果脚本未中止,则返回 0。如果中止,则不返回。
log
将指定表达式打印到用户界面的测试日志中(该日志也会包含在测试报告中)
返回相同的字符串。
match ,
匹配两个表达式。返回1如果 包含在 否则为0。
可能是一个包含常规通配符、正则表达式语法等的正则表达式。
set =
Assign the value to the variable specified which may be used in other expressions.
Returns the value of the expression.
Examples of scripts:
; script that will login to DUT
log "Login to DUT..."
log recuntil "login: "
sendln "admin"
recuntil "Password: "
sendln "12345"
recuntil " >"
log "Login successfull..."
; check if version of DUT is 5.2 as obtained by the system resource print command
sendln "system resource print"
log recuntil " >"
log recuntil " >"
set reply= recuntil " >"
log reply
failif not match "version: 5.2", reply
log "Version of DUT is correct ..."