bash Telnet - 在一行中连接和发送消息

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29865659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 12:52:42  来源:igfitidea点击:

Telnet - Connect and send message in one line

bashshelltelnet

提问by Dan

I'm looking for a one-line command that will connect to a telnet server (no authentication needed, it will accept any connection) and send text to the server after connection.

我正在寻找将连接到 telnet 服务器(无需身份验证,它将接受任何连接)并在连接后向服务器发送文本的单行命令。

If this is not possible, is it possible to write a script that will do the same thing?

如果这是不可能的,是否可以编写一个脚本来做同样的事情?

回答by Cyrus

With bash: replace "servername" by your telnet server:

使用 bash:用您的 telnet 服务器替换“servername”:

echo "Hello" > /dev/tcp/servername/23

回答by alex.feigin

Sounds like you can use Netcaton the telnet port.

听起来您可以在 telnet 端口上使用Netcat

An example would go like so:

一个例子是这样的:

echo -n 'some string to telnet' | nc <server> 23