views:

29

answers:

2

I have 2 machines A and B.

In machine A, I do

echo "Hello World" > /dev/tcp/{Bs_ip}/12345

In machine B, how do I write a script that runs in the background, listens on port 12345, and prints whatever it receives from port 12345 to stdout?

BTW both machines are running Red Hat Enterprise Linux AS 4.

Thanks

+1  A: 

You can do that using netcat:

nc -l -p 123456

If you want to be able to handle multiple connections you will have to use a loop.

Bart Sas
A: 

You can use netcact (nc) or netcat on steroids, ie socat. I gave a link to the examples section of the man page, so that you can see how powerful socat is.

socat TCP4-LISTEN:12345 - 

Should do what you want

shodanex