Netcat and file transfer

netcat

How do I actualy use netcat to transfer files over network? IIRC something like that nc -l -p 12345 > destfile(on the receiving end) + dd if=/dev/sourcedevice| nc ipaddress 12345(on the sending end) used to work. That is when the transfer was complete the sending process finished , terminated the tcp connection so the receiving process did quit as well. But now, the sending process just hangs (as if it could transfer anything after EOF) so the receiving process hangs as well. This is totally non scriptable.

I also tried -c on the sending end but that couses the destfile to be of random size (almost the expected size). Or maybe there is some reliable alternative to netcat?

Best Answer

What I always do is:

nc -l -p 12345 > destfile
nc ipaddress 12345 < sourcefile
Related Topic