You can use netcat
. In this minimal example, you can pipe the output of cat
to netcat
using:
cat local-filename.txt | netcat remote-hostname 1234
Where 1234
represents the TCP port that is going to be used. In the receiving side, you can use:
netcat -l 1234 > filename-on-remote-host.txt
where -l
indicates you are setting up a server. This connection will be closed when the originating netcat process finishes. If you need it to keep going and waiting for the next connection, you can use the -k
option:
netcat -kl 1234 | some-receiving-command
In any case you can use the abbreviated nc
instead of the full netcat
:
nc -kl 1234 | some-receiving-command