#!/usr/bin/expect -f
spawn telnet IP PORT
expect "Escape character is '^]'"
send loadtime
set accum {}
expect {
-regexp {..*} {
append accum "${accum}$expect_out(0,string)"
exp_continue
}
}
puts $accum
loadtime命令的输出类似于“加载时间:2.45” 但是,在执行脚本时,$ accum仅显示“loadtime”而不显示“Load Time:2.45”
如何在变量或本地文件中捕获loadtime命令的输出?
答案 0 :(得分:0)
您忘记按Enter键:send "loadtime\r"