2

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.

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

But it didn't work.

4

1 回答 1

3

使用socat而不是 netcat。像这样的东西:

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

要对其进行测试,您可以打开另一个终端,并使用 socat 桥接 stdio 和 UDP 套接字:

socat - UDP:localhost:5555

输入 ping,你会得到 pong !

于 2011-03-14T13:47:27.337 回答