Using nc to transfer large file

On receiving end:

nc -l 1234 > file.tar.gz

On sending end:

cat file.tar.gz | nc <reciever's ip or hostname> 1234

That should work. Depending on the speed, it may take a while but both processes will finish when the transfer is done.


from the sender

nc -v -w 30 1337 - l < filename

where "-v" from verbose, "-w 30" for a wait before and after 30 sec for the connection, "1337" port number, "-l" tell nc that this is a sender

from the receiver nc -v -w 2 ip_add_of_sender 1337 > filename


From the nc(1) man page:

-l Used to specify that nc should listen for an incoming connection rather than initiate a connection to a remote host. It is an error to use this option in conjunction with the -p, -s, or -z options.

So your use of -p is wrong.

Use on server2:

nc -l 1234 > file.tar.gz

And on server1:

nc server2 1234 < file.tar.gz

Tags:

Linux