# Remind me to write a version of this in terms of http_get (tcl8.0 and later). # if {1 != $argc} { puts "Usage: 'identify_server.tcl HOST'." puts "This utility then describes the Web server in use on host HOST." exit 1 } set host [lindex $argv 0] if [catch {socket $host 80} s] { puts "HTTP service is not available on port 80 of host '$host'." exit 1 } fconfigure $s -buffering line puts $s "HEAD http://$host HTTP/1.0\n" while {1} { if [eof $s] { puts "Some error message." exit 1 } gets $s line if [regexp "^Server: (.*)" $line x server] { puts \ "For host '$host', the server identifies itself as '$server'." exit } }