您好,expect脚本(名字为aaa)大概如下:
#!/usr/bin/expect
spawn telnet 192.168.1.101 2345
sleep 5
send "config show\r"
sleep 1
send "quit\r"
expect eof
终端执行的输出为:
root@tj-lc1 ~ #
expect aaa
spawn telnet tj-lc1 15551
Trying 192.168.1.101...
Connected to 192.168.1.101.
Escape character is '^]'.
config show
quit
configuration:
default_request_timeout..........[2000]
default_request_resend_attempts..[3]
Goodbye!
Connection closed by foreign host.
我想修改aaa脚本,将default那两行输出弄到变量或文件里,有什么方法吗?
谢谢