RetroBSD
http://retrobsd.org/

Easy file transfer with nc(1)
http://retrobsd.org/viewtopic.php?f=13&t=37530
Page 1 of 1

Author:  ibara [ Tue Feb 09, 2016 10:01 pm ]
Post subject:  Easy file transfer with nc(1)

Netcat, aka nc(1), is a great networking tool that does just about anything you can think of.
You can also use it as a quick file transfer client/server. I was getting frustrated that I couldn't get ftp(1) to transfer files off of my LiteBSD QEMU image but then I remembered that this is exactly why I ported nc(1) to LiteBSD.

We know that LiteBSD already has nc(1) but you need to make sure that your server has it (just type 'nc' at a terminal on the server: if it does something then you're good).

You need to setup the server first. The command is:
Code:
$ nc -l -p 22222 > file

You can change 22222 to whatever port number you want to use and file to the name you want the received file to have.
The server will now sit patiently and wait until something sends data to port 22222.

Now, on your LiteBSD machine, issue this command:
Code:
$ nc hostname 22222 < file

Where hostname is the IP address of the server (if you are on QEMU and want to send a file to the host machine, the hostname is 10.0.2.2), and file is the name of the file you want to send.

And that's it! nc(1) will quit automatically on both ends once the file transfer is finished.
Remember though that these file transfers are unencrypted, so best to do this on a LAN and not over the open Internet.

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/