且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在使用Expect'send'命令的同时将输出存储在变量中

更新时间:2023-01-16 08:09:51

也许:

log_user 0                   ;# turn off the usual output
spawn telnet@ip 
expect -re "*login*"
send "root\r"
expect -re "password*"
send "****\r"
send "ovs-vsctl *******"
expect eof
puts $expect_out(buffer)     ;# print the results of the command