[Reinhard Max] - 2004-11-08 This little tool allows to create tiny URL (http://tinyurl.com) from the command line. The TinyURL proc can also be used in other scripts for TinyURL creation. package require http # - TinyURL # # Create a simple alias URL from a possibly long and complicated one # using the http://tinyurl.com service # # in: The URL to be made tiny # out: The tiny URL # proc TinyURL {url} { set query [::http::formatQuery url $url] set token [::http::geturl http://tinyurl.com/create.php -query $query] if {[::http::ncode $token] != 200} { return -code error [::http::data $token] } set RE {^$} if {![regexp -line $RE [::http::data $token] -> turl]} { return -code error \ "http://tinyurl.com has probably changed the output format." } ::http::cleanup $token return $turl } if {$argc != 1} { puts "usage: [info script] url" exit 1 } puts [TinyURL [lindex $argv 0]]