2013-05-08 117 views
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 

加載時命令的輸出看起來像「加載時間:2.45」 然而,在執行該腳本,$ ACCUM只顯示「加載時」,而不是「加載時間:2.45」如何使用expect_out捕獲expect腳本命令的輸出?

如何捕獲的輸出loadtime命令在變量或本地文件中?

回答

0

您忘了按Enter鍵:send "loadtime\r"

+0

Thanks @glenn jackman – user2325313 2013-05-09 18:28:29