wcp: a simple HTTP URL cp for UNIX


More and more developers of applications/programs/other stuff on the Internet are now beginning to distribute their files via HTTP only. One drawback for people who do not have the fastest lines in the world, is that you cannot retrieve a document and have your proccess in the background.

So I've built this simple but very helpful script named wcp which simply copies the URL in question. It uses the netcat program which is developed by: *Hobbit* (hobbit@avian.org). Netcat is available from the following URL: ftp://ftp.avian.org/src/hacks/. If you do not want to use netcat you may substitute nc with telnet.

#!/bin/sh 
# @(#)wcp.sh, copy web pages, adamo@dblab.ntua.gr

[ $# -ne 1 ] && {
        echo Usage: wcp http://host:port/path/name
        exit 1
}

proto=`echo $1 | cut -d: -f1`
host_port=`echo $1 | cut -d/ -f3`
host=`echo $host_port | cut -d: -f1`
port=`echo $host_port | cut -d: -f2`
pathname=`echo $1 | cut -d/ -f4-`
file=`echo $pathname | awk -F"/" '{print $NF}'`

exec 2>${file}.wcplog
exec 1>$file
echo GET /${pathname} | nc $host $port

exit $?
# end of file
-- adamo@dblab.ntua.gr -.