0

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?

2
  • Which /dev-device are you using? Could you please add a real example of what is not working?
    – Patrick B.
    Feb 10, 2013 at 19:51
  • I want to transfer part of /dev/mapper/mainvg-rootlv. But it really makes no difference as the point is that netcat does not react to EOF (no matter if it is a real file, part of a file, or Ctrl-D from keyboard). Feb 12, 2013 at 10:29

1 Answer 1

1

What I always do is:

nc -l -p 12345 > destfile
nc ipaddress 12345 < sourcefile
3
  • This might be ok, if you have the file on filesystem. But it won't do if you want to transfer only part of the file, by giving additional options to dd. Feb 10, 2013 at 17:23
  • so you expect nc to get an EOF while you are only sending part of the file? Feb 10, 2013 at 17:37
  • I mean EOF as end of input. In case of dd if=/dev/sourcedevice bs=1M count=1 the EOF should happen after 1MiB. Feb 10, 2013 at 19:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.