Posted to tcl by venks at Fri Nov 04 08:25:22 GMT 2011view pretty

#!/c:/tools/tcl/8.4.4/bin/tclsh84.exe

 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"

Comments

Posted by arjen at Fri Nov 04 10:49:21 GMT 2011 [text] [code]

Here is my extended version: #!/c:/tools/tcl/8.4.4/bin/tclsh84.exe # # Minimal wget implementation # For use in kitcreator! # package require http if { [llength $argv] == 1 } { set url [lindex $argv 0] set filename [file tail $url] } else { # # Pattern: -O outfile url # set filename [lindex $argv 1] set url [lindex $argv 2] } 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"