Hey,
Here's one I just hacked together for fun. It uses netcat. It
understands redirects, but that's it.
-----8<-----
#!/bin/sh
if test $# -ne 1; then
echo "usage: $0 url" >&2
exit 1
fi
wget (){
url="$(echo "$1" | sed 's/^http:\/\///')"
host="$(echo "$url" | sed 's/\/.*//')"
path="$(echo "$url" | sed 's/[^/]*//')"
printf "GET $path HTTP/1.1\r\nHost: $host\r\n\r\n" | nc -vv -w 1 "$host" 80 (
read http code mesg
if test "$code" -eq 200; then
while read header; do
if test "$header" = "$(printf '\r')"; then
break
fi
done
cat
elif test "$code" -eq 301 -o "$code" -eq 302 -o "$code" -eq 307; then
while read key val; do
if test "$key" = 'Location:'; then
wget "$val"
break
fi
done
else
echo "unknown http code: $code $mesg"
fi
)
}
wget "$1"
-----8<-----
Thanks,
cls
Received on Sat May 28 2011 - 01:34:16 CEST
This archive was generated by hypermail 2.2.0 : Sat May 28 2011 - 01:36:03 CEST