P i
P i

Reputation: 30714

How to send stdout of one Python program over UDP to stdin of another using BASH?

I'm running foo.py on Ubuntu box A, and I want to feed its stdout as stdin to bar.py running on Ubuntu box B.

I think python foo.py | /dev/udp/12.34.56.78:1234 will send out of box A to box B, but how can I pick up the packets and feed them into bar.py?

I need something like udp_listener localhost:1234 | bar.py but (if that's correct) what's the actual syntax?

Upvotes: 0

Views: 144

Answers (1)

Philippe
Philippe

Reputation: 26707

On your Ubuntu box B, run

nc -klu -p 1234 | cat

On your Ubuntu box A, run

echo "Hello world" > /dev/udp/12.34.56.78/1234

If this works, replace cat with bar.py and replace echo "Hello world" with python foo.py

You may need to open firewall for boxB:1234/udp

Upvotes: 1

Related Questions