与聊天庆典上自动UDP响应相结合的netcat [英] combine netcat with chat on bash for automatic udp responses

查看:165
本文介绍了与聊天庆典上自动UDP响应相结合的netcat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想结合聊天和NC在Linux上,所以我会创建响应于特定请求并发送回一个答案。一个小小的UDP服务器

I want to combine "chat" and "nc" on linux, so I will create a tiny udp server that responds on a specific request and sends back an answer.

其实我是想以NC的标准输出重定向到的聊天,反之亦然标准输入。我的第一个尝试是:

In fact I want to redirect the stdout of "nc" to the stdin of "chat" and vice versa. My first attempt was:

nc -w 3000 -u -n -l -p 30000 >&1111 <2222 & 
chat -V 'request' 'answer' >&2222 <1111

但它没有工作。

推荐答案

使用的 socat 而不是netcat的。事情是这样的:

use socat instead of netcat. Something like this :

socat UDP-LISTEN:5555 EXEC:"chat -sv ping pong",pty

要测试它,你可以打开另一个终端,并使用socat弥合标准输入输出和一个UDP套接字:

To test it, you can open another terminal, and use socat to bridge stdio and an UDP socket :

socat - UDP:localhost:5555

键入ping,你会得到乒乓球!

Type ping, and you will get pong !

这篇关于与聊天庆典上自动UDP响应相结合的netcat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆