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

Time:01-15

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?

CodePudding user response:

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

  •  Tags:  
  • Related