Network Redirection: UDP/TCP to a File

I just learned a cool bash trick. Redirecting network traffic to a file.

Open two bash terminal windows.

t1$ nc -l 7777 >> TESTFILE
t2$ exec 3<>/dev/tcp/127.0.0.1/7777
t2$ echo 'Hello World!' >&3
t1$ cat TESTFILE

Your TESTFILE now has Hello World! in it.

There are quite a few ways to do this and similar operations, easy found on the Googles.

*Note: Other shells may work, I used bash. Your shell may or may not have redirection capabilities built into it.

Leave a Reply

Your email address will not be published. Required fields are marked *