Author: Mayank Sharma
Woof is a temporary Web server that is invoked when you want to transfer files. When a file is on offer, the recipient can download it using a browser or through wget, a popular command-line download utility.
Basic usage
To use Woof, make sure you have Python installed. Download the Woof Python script and save it someplace where it’s easily accessible, such as /usr/local/bin/woof. Make the file executable with chmod +x woof
. Don’t forget to note down your IP address as printed by ifconfig
. For the article I’ll use 192.168.0.117 as the default IP address.
Woof needs your IP address and a free port on your computer through which its temporary Web server can serve the file. Once it’s up and running, Woof will spit out a URL that the recipient can use. For instance:
$ woof -i 192.168.0.117 -p 8888 somefile.txt Now serving on http://192.168.0.117:8888/
In this example, we specify our IP address and the port with the -i
and -p
options, followed by the file we need to transfer. Woof acknowledges, printing the complete URL the recipient needs to type into a Web browser to get the file.
Once the file has been downloaded, the temporary Web server quits, and Woof prints an entry in the common log format that looks like:
192.168.0.1 - - [07/Feb/2007 21:31:51] "GET /somefile.txt HTTP/1.1" 200 -
The entry begins with the recipient’s IP address — in this case, 192.168.0.1 — followed by the time at which Woof finished the file transfer, enclosed in brackets. Next comes the request line from the recipient enclosed in quotes. It reveals the transfer method employed by the recipient (GET), the name of the resource requested (/somefile.txt), and the protocol used (HTTP/1.1). All this information is suffixed with a W3C-compliant status code that reveals whether the request resulted in a successful response (codes beginning in 2), an error caused by the client (codes beginning in 4), or an error in the server (codes beginning in 5).
Transferring multiple files to several recipients
The example above is useful for transferring a single file to a single recipient, but it’s also easy to share the file with multiple recipients.
$ woof -i 192.168.0.117 -p 8888 -c 2 somefile.txt Now serving on http://192.168.0.117:8888/ 192.168.0.112 - - [07/Feb/2007 22:53:29] "GET /somefile.txt HTTP/1.0" 200 - 192.168.0.118 - - [07/Feb/2007 22:55:34] "GET /somefile.txt HTTP/1.0" 200 - $
With the -c
option you can specify the number of times a file can be downloaded. By default Woof sets this count to 1. In the example above, we set the count to 2 and Woof exits when the file has been downloaded twice, printing two log entries.
In the foregoing examples we transferred only a single file. Transferring multiple files isn’t all that different:
$ woof -i 192.168.0.117 -p 8888 my_files/ Now serving on http://192.168.0.117:8888/
This will transfer the directory my_files/. To ease transportation, Woof will create a tar archive of the directory and compress it with gzip. In the example above, the recipient will download a file called my_files.tar.gz, which he can uncompress and untar with the command tar zxvf my_files.tar.gz
.
The time it takes to compress a directory depends upon its size. If you are on a fast network and don’t want to wait for the directory to be compressed, use the -u
option, which will forgo the compression process:
$ woof -i 192.168.0.117 -p 8888 -u some_more_of_my_files/ Now serving on http://192.168.0.117:8888/
This creates a .tar archive that you can untar using the tar xvf some_more_of_my_files.tar
command.
As with single files, you can use the -c
option to specify how many times you need the compressed directory to be available for download.
However, Woof can transfer only single files or a single directory. It’s not designed to transfer multiple files from multiple locations at one go. For that you’d need to spawn multiple Woof instances, or group all files under one directory.
Also remember that Woof can only offer one file over one port. If you use multiple instances of Woof simultaneously to offer multiple files, you’ll need to use different ports.
Customizing default options
To simplify the options specified by the woof
command, you can specify some default values in a resource script file. Suppose you have a fixed IP address from which you need to always transfer two copies of every file or directory, and the directories should never be compressed. Create a .woofrc file under your home directory and enter the following values in it:
[main] ip = 192.168.0.117 port = 8888 count = 2 compressed = false
Now you can simply say woof somefile.txt
without the IP and port information to share two copies of the text file, or woof some_directory/
to offer two uncompressed copies of the specified directory.
As you can see, using Woof is pretty simple and straightforward — but wait, there’s more! What do you do when a recipient wants to share some files? No need to ask him to grab a copy of Woof from its download site. Instead, use the -s
option instead of specifying any file or directory:
$ woof -i 192.168.0.117 -p 8888 -s Now serving on http://192.168.0.117:8888/
When the recipient types in the download URL, he will be served a copy of Woof itself. How cool is that?
I’ve been using Woof for zipping files over my network ever since I found it. It handles files of all forms and sizes. I’ve successfully transferred directories containing several gigabytes of files and even DVD ISO images simultaneously, over wired and wireless networks, to a computer running Windows. With its bare minimum requirements, and negligible size, it’s a handy utility.