Version 5 of minimalist wget

Updated 2006-03-19 02:28:09

2004-10-29 VI This is a 10 line replacement for the far-more-capable wget program. This only works for http and just gets a url and puts it in a file. To invoke - have an alias like this:

 alias wget '/usr/local/tcl/8.4.7/bin/tclsh8.4 ~/tcltools/wget.tcl \!*'

And use it as

 wget http://mini.net/tcl/12871

Code for wget.tcl - only requires the tcl core:

 package require http
 set url [lindex $argv 0]
 set filename [file tail $url]
 set r [http::geturl $url -binary 1]
 set fo [open $filename w]
 fconfigure $fo -translation binary
 puts -nonewline $fo [http::data $r]
 close $fo
 ::http::cleanup $r
 puts "Got $url -> $filename"

male - 30th October 2004:

If the file should be written in binary mode, then the data should be requested and transfered as binary too!

I changed the code above to get the url in binary mode.


Category Application - Category Internet