【发布时间】:2018-10-02 10:06:55
【问题描述】:
我需要在没有任何人工干预的情况下获得准确的 telnet 输出
-bash-4.2# echo exit | telnet localhost 22
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
Connection closed by foreign host.
-bash-4.2# telnet localhost 22
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
SSH-2.0-OpenSSH_7.4
这里使用telnet localhost 22时显示“SSH-2 OpenSSH_7.4”,但在echo exit | telnet localhost 22中没有显示
输出:
bash-4.2# echo exit | telnet localhost 22
Trying ::1…
Connected to localhost.
Escape character is ‘^]’.
Connection closed by foreign host.
telnet> quit
Connection closed.
-bash-4.2#
我也尝试过以下 cmets “连接已关闭。”
-bash-4.2# cat < /dev/tcp/localhost/22
SSH-2.0-OpenSSH_7.4
^C
-bash-4.2# echo exit | cat < /dev/tcp/localhost/22
SSH-2.0-OpenSSH_7.4 (I want to execute and close automatically)
【问题讨论】:
-
您想要完成的究竟是什么?例如,如果您只需要捕获输出并编写输入脚本,则可以考虑使用 Netcat。如果这不是您的目标,请尝试更好地解释它。
-
得到了答案老兄,我想捕获确切的输出,感谢您的时间
-
当你有一个你喜欢的答案时,选择最适合你的答案,然后
accept那个答案。