netrw is a simple (but powerful) tool for transporting data over the internet. Its main purpose is to simplify and speed up file transfers to hosts without an FTP server. It can also be used for uploading data to some other user. It is something like one-way netcat (nc) with some nice features concerning data transfers. Netrw can compute and check message digest (MD5, SHA-1, and some others) of all the data being transferred, it can also print information on progress and average speed. At the end it sums up the transfer.
netrw can also be found at freshmeat.net
Typical usage of netrw tool
Let's suppose you want to send a file named data.zip from host.domain.org to server.somewhere.net. There are several ways how this can be done. The first and the second example are the same for Unix-like OSs as well as for Windows "OS". In case of Windows, it's better and safer to use -i and -o parameters rather than I/O redirection. The third example is only usable on Unix-like systems because Windows (not speaking about cygwin and other similar tools) has no ssh.
-
basic and the most usual scenario:
- on server.somewhere.net run
$ netread 1234 >data.zip
or$ netread -o data.zip 1234
- on host.domain.org run
$ netwrite server.somewhere.net 1234 <data.zip
or$ netwrite -i data.zip server.somewhere.net 1234
- on server.somewhere.net run
-
when the server is protected by firewall (and the host is not) or when you
want the connection to be initiated by reader, you have to use this
scenario:
- on host.domain.org run
$ netwrite -f 1234 <data.zip
or$ netwrite -i data.zip -f 1234
- on server.somewhere.net run
$ netread -f server.somewhere.net 1234 >data.zip
or$ netread -o data.zip -f server.somewhere.net 1234
- on host.domain.org run
-
when you are both writer and reader, you can run the following commands on
one of the two machines only:
- on host.domain.org run
$ ssh server.somewhere.net 'netread 1234 >data.zip' &>/dev/null & $ netwrite server.somewhere.net 1234 <data.zip
- OR on server.somewhere.net run
$ netread 1234 >data.zip 2>/dev/null & $ ssh host.domain.org 'netwrite server.somewhere.net 1234 <data.zip'
- on host.domain.org run
When you want to send more than one file, you have to use a bit complicated commands:
- On Unix-like systems you can make use of tar and pipes:
$ netread 1234 | tar xf - $ tar cf - <some_files> | netwrite server.somewhere.net 1234
- Windows: first you have to compress those files into one file (e.g., using WinZip), send the compressed file to the remote host (as it is described above) and there you have to uncompress it.