0
#!/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 命令的输出看起来像 "Load Time: 2.45" 但是,在执行脚本时,$accum 只显示 "loadtime" 而不是 "Load Time: 2.45"

如何在变量或本地文件中捕获加载时间命令的输出?

4

1 回答 1

0

您忘记按 Enter 键:send "loadtime\r"

于 2013-05-09T10:37:03.647 回答