Those wacky netpipes!
⇐ Back to Networking
Questions, comments, or corrections? Send me a message.
I don't know about other distros, but Slackware has always come with netpipes. I always installed it, like a good user, but for a long time I didn't know what they did. After finding out I never knew how I lived without them.
The netpipe package does exactly what the name says, it allows you to connect pipes over a network. For those not following, I'm sure you've seen this before:
gzip -d -c file.tgz | tar xvf -
Well, there you have a pipe, you are piping the output of one command in to another command. Netpipes let's you do this over the network, so you can attach the output or input of one command to another over the network. For a simple example:
faucet 9876 -out cat /etc/hosts
This creates a faucet in netpipe lingo that you can attach a hose to later. The first number is the port to attach the pipe to and the -out means attach STDOUT of the command to the port, with all remaining arguments to be the command to run. Well, that's nice and all, but what do we do with it? Log in to another machine or terminal on the same machine and do this:
hose ip.of.first.machine 9876 -in cat
After running the command, and substituting the ip.of... stuff with the IP address of the first machine, you should see the contents of the /etc/hosts file from the first machine spit out. If you used another terminal instead of another machine, you can just use localhost for the test, but netpipes are pretty ineffective locally. :) Anyway, back to the point. What is the point? Well, if you don't realize it, this is a pretty powerful userland tool. Lets say, for example, you have a repository of stuff on machine A and want to move it to machine B. Furthermore, there is no FTP access on either machine. What to do? If you're lucky you might be able to make a public_html directory if a webserver is running, but that's out of your control. You could email it to yourself, but if the files are large they might not make it. The easiest answer, if you have netpipes, is to tar them up on one machine and untar them on the remote machine. On machine A you would run:
faucet 9876 -out tar cv somedir/
And on machine B you would run:
hose ip.of.machine.A -in tar xv
And watch as machine A tars up the directory, and then it's shoved out the netpipe to machine B where it is untarred. Very cool indeed. No programs to write, no contacting the admin to ask if you can move your 1.5gig vcd... err... book collection and wanting FTP, etc. You can do it on your own with no special priveleges.
Some caevats to watch out for. The faucet doesn't terminate after a client connects, so make sure you kill the command unless you want the archive to always be availabe (cheap backup, etc). Also, there's no restricting access as far as I can tell. It's all or none.
So that sums it up. Create a faucet on one machine, bind it to a port and command, then on another machine hook a hose to that faucet and suck up your data. Couldn't get any simpler.