让 telnet 在一行中执行单个命令 [英] let telnet execute single command in one line
本文介绍了让 telnet 在一行中执行单个命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嘿,我可以使用telnet localhost 4242"登录到 telnet,现在我想执行一个命令show network".
hey i can login into telnet with "telnet localhost 4242" now i want to execute a single command "show network".
我怎样才能在一行中做到这一点?
How can i do this in one line ?
类似的东西
$ telnet localhost 4242 <-显示网络"
$ telnet localhost 4242 <- "show network"
哇这里是我想要的输出
推荐答案
I found expect 做我想做的事,等待某个输出然后采取行动:
I found expect to do exactly what i want, wait for a certain output and then act upon it:
expect << EOF
spawn telnet localhost 4242
expect -re ".*>"
send "show network\r"
expect -re ".*>"
send "exit\r"
EOF
这篇关于让 telnet 在一行中执行单个命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文