--- /dev/null
+#! /bin/sh
+# -*- tcl -*- \
+exec tclsh "$0" ${1+"$@"}
+
+# Script to create a short url via http://tinyurl.com
+# right away from the command line.
+
+# Copyright (c) 2007 Sven Hoexter <sven@timegate.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
+
+# For updates see http://sven.stormbind.net/misc/
+
+### Changelog
+# Version: 0.1 2007-04-15
+# - initial release
+
+### required external (Debian) packages are:
+# - tclcurl for TclCurl
+# - tcllib for htmlparse etc.
+
+package require TclCurl
+package require http
+package require htmlparse
+package require struct
+
+proc parse {rpage} {
+ ::struct::tree t
+ htmlparse::2tree $rpage t
+ htmlparse::removeVisualFluff t
+ htmlparse::removeFormDefs t
+ foreach nodeakt [t children -all [t rootname]] {
+ #puts "DEBUG: [t getall $nodeakt ] NODE: $nodeakt"
+ if {[t get $nodeakt type] == "PCDATA"} {
+ set nodedata [t get $nodeakt data]
+ if {[string match -nocase "*http://tinyurl.com*" $nodedata]} {
+ puts $nodedata
+ puts ""
+ }
+ }
+ }
+}
+
+
+proc main {argv} {
+ #puts "DEBUG: $argv"
+ regsub -all "(http://)" $argv "" saneargv
+ #puts "DEBUG: $saneargv"
+ set useragent "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.12) Gecko/20050922"
+ set uri http://tinyurl.com/create.php?
+ append uri [http::formatQuery url $saneargv]
+ #puts "DEBUG: $uri"
+
+ set chandle [curl::init]
+ $chandle configure -url $uri \
+ -useragent $useragent \
+ -autoreferer 1 \
+ -followlocation 1 \
+ -bodyvar rpage
+ $chandle perform
+ $chandle cleanup
+
+ parse $rpage
+}
+
+main $argv
\ No newline at end of file