Updated 2008-11-12 10:38:01 by dkf

A simple tool to determine the status of a web site. Type a URL in the "Web Site:" text field, then press return or click the "Get Status" button. The HTTP status, code, filesize (in bytes) and raw HTML output will be displayed for the requested resource. - WJR

Bookmarks can be stored in a file called 'status-bookmarks.txt'. The file should reside in the same directory as this application.

escargo 3 Aug 2003 - I used the wish-reaper to reap this page, but running the application I found a couple of things that might be considered flaws:

  • There is no way to save the page that is retrieved. I can see where that might be really useful in some cases.
  • There are no horizontal scroll bars. When I had long lines, I could not resize the application, nor would the long lines wrap.

I agree, these flaws are due to my lack of Tk GUI-building experience. I appreciate these suggestions! - WJR

Download Web Site Status [1], or the source code appears below.

Screenshot:

Source Code:
 #!/bin/sh
 #
 # status.tcl --
 #
 #    GUI-based tool to check the status of a web site
 #
 #    $Author: jcw $
 #    $Date: 2003-08-04 08:00:43 $
 #    $Revision: 1.10 $
 #
 # -*- tcl -*-
 # The next line is executed by /bin/sh, but not tcl \
 exec tclkit "$0" ${1+"$@"}

 package require Tk
 package require http

 proc get_status {this_site} {

     global site
     global status
     global code
     global size

     set code {Connecting...}
     update idletasks

     # If user prepended site with http://, get rid of it
     regsub http:// $this_site "" this_site

     set result [catch {set token [http::geturl http://$this_site]} msg]

     # Delete any information in the text widget
     .html.html_out configure -state normal
     .html.html_out delete 0.0 end

     if {$result == 0} {
	 set status [http::status $token]
	 set code [http::code $token]
 	set size [http::size $token]
 	set html [http::data $token]
 	.html.html_out insert end $html
     } else {
 	set status ""
 	set code ""
 	set size ""
 	tk_messageBox -icon error -message $msg \
 	       -parent . -title Error -type ok
     }

     .html.html_out configure -state disabled
 }

 proc about {} {
     .html.html_out configure -state normal
     .html.html_out delete 0.0 end

     set about {
 Web Site Status ($Revision: 1.10 $, $Date: 2003-08-04 08:00:43 $):

 A simple tool to determine the status of a web site. Type a URL in the
 "Web Site:" text field, then press return or click the "Get Status" button.
 The HTTP status, code, filesize (in bytes) and raw HTML output will be
 displayed for the requested resource.

 Bookmarks can be stored in a file called 'status-bookmarks.txt'. The file
 should reside in the same directory as this application.

 Bug reports and requests for enhancements can be sent to [email protected].
     }

     .html.html_out insert end $about

     .html.html_out configure -state disabled
 }

 proc go_bookmark {this_bookmark} {
     global site
     set site $this_bookmark
     get_status $this_bookmark
 }

 # Clear all the form fields
 proc clear_form {} {
     global site
     global status
     global code
     global size
     set site ""
     set status ""
     set code ""
     set size ""
     .html.html_out configure -state normal
     .html.html_out delete 0.0 end
     .html.html_out configure -state disabled
 }

 # Set a title for the window
 wm title . "Web Site Status"
 wm minsize . 80 20
 wm maxsize . 80 20

 # Configure the menubar
 frame .mbar
 pack .mbar -side top -fill x

 menubutton .mbar.file -text File -menu .mbar.file.menu -underline 0
 menubutton .mbar.help -text Help -menu .mbar.help.menu -underline 0
 menubutton .mbar.bookmarks -text Bookmarks -menu \
	 .mbar.bookmarks.menu -underline 0
 pack .mbar.file .mbar.bookmarks .mbar.help -side left

 menu .mbar.file.menu -tearoff 0
 menu .mbar.bookmarks.menu -tearoff 0
 menu .mbar.help.menu -tearoff 0

 .mbar.file.menu add command -label Quit -underline 0 -accelerator "Ctrl+Q" \
	 -command exit
 .mbar.help.menu add command -label About -underline 0 -command about

 # Populate the Bookmarks menu
 if {[file exists "./status-bookmarks.txt"]} {
     set bookmarks [open "./status-bookmarks.txt" r]
     while { [gets $bookmarks bookmark] >= 0 } {
	 .mbar.bookmarks.menu add command -label $bookmark -command \
 		"go_bookmark $bookmark"
     }

     close $bookmarks
 }

 #frame .sep -height 2 -borderwidth 2 -relief sunken
 #pack .sep -side top -fill x -padx 1m -pady 1m

 # Widgets to display the controls
 frame .controls
 label .controls.site_label -text "Web Site:"
 entry .controls.site_entry -relief sunken -textvariable site -width 40
 button .controls.site_get -text "Get Status" \
	 -command {get_status $site}
 pack .controls.site_label -side left
 pack .controls.site_entry -side left -padx 1m
 pack .controls.site_get -side left
 #pack .controls.site_clear -side left

 pack .controls -side top -padx 1m -pady 1m -fill x

 # Widgets to display the code and status
 frame .output
 label .output.status_label -text "Status:"
 entry .output.status_entry -textvariable status -state readonly -width 10

 label .output.code_label -text "Code:"
 entry .output.code_entry -textvariable code -state readonly -width 40

 label .output.size_label -text "Size:"
 entry .output.size_entry -textvariable size -state readonly -width 10

 pack .output.code_label -side left
 pack .output.code_entry -side left

 pack .output.status_label -side left
 pack .output.status_entry -side left

 pack .output.size_label -side left
 pack .output.size_entry -side left

 pack .output -side top -padx 1m -pady 1m -fill x

 # Text widget to display the raw HTML output
 frame .html
 text .html.html_out -relief sunken -bd 1 -yscrollcommand \
	 ".html.html_scroll set" -width 80  -height 20 -state disabled \
 	-wrap none
 .html.html_out configure -setgrid 1
 scrollbar .html.html_scroll -command ".html.html_out yview"

 pack .html.html_out -side left
 pack .html.html_scroll -side right -fill y
 pack .html -side top -padx 1m -pady 1m

 # Buttons for various functions
 frame .buttons
 button .buttons.clear -text "Clear Results" -command clear_form
 button .buttons.quit -text "Quit" -command {exit}

 pack .buttons.clear -side left -padx 1m
 pack .buttons.quit -side left -padx 1m
 pack .buttons -side bottom -padx 1m -pady 2m

 # Bindings
 bind .controls.site_entry <Return> { get_status $site }
 bind all <Control-q> {exit}