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.

1
  • I believe file descriptors have to be between 0 and 255. You should probably use named pipes instead anyway. Commented Mar 12, 2011 at 21:27

1 Answer 1

3

use socat instead of netcat. Something like this :

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

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

socat - UDP:localhost:5555

Type ping, and you will get pong !

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.