Handy Macintosh AppleScript to bounce the VNC server via cgi

Kevin McGough kamcgough "at" mac.com
Sat, 09 Mar 2002 02:43:43 +0000


as a cgi,  you can bounce a hung server (from Apple Personal Web Server, or
anything that supports cgi.)  This is a chunk of code that will work for you.

property crlf : (ASCII character 13) & (ASCII character 10)

--this builds the normal HTTP header for regular access
property http_10_header : "HTTP/1.0 200 OK" & crlf & "Server: MacHTTP" & crlf
& ,
 "MIME-Version: 1.0" & crlf & "Content-type: text/html" & crlf & crlf

on handle CGI request path_args ,
 searching for http_search_args with posted data post_args using access method
method from address client_address ,
 from user username using password |password| with user info from_user from
server server_name ,
 via port server_port executing by script_name of content type content_type
referred by referer ,
 from browser user_agent with full request all_headers given +class
auth;:authorization, +class host;:|host|
 --This is WEIRD syntax. What it really means is that you have the variables
 -- path_args, http_search_args, client_address, username,  password, etc. to
play with.
 -- They are all strings.
 
 try --wrap the whole script in an error handler
  if http_search_args = "Bounce" then
   tell application "VNCServer PPC"
    quit
   end tell
   tell application "Finder"
    activate
    select file "VNCServer PPC" of folder "Startup Items" of folder "System
Folder" of startup disk
    open selection
   end tell
  end if
return http_10_header & "<title>Test CGI</title><h2>Test CGI</h2><u>CGI
arguments sent:</u>" & ,
   "<br><b>path:</b> " & path_args & ,
   "<br><b>all_headers:</b> " & all_headers & crlf
 on error msg number num --report the error message and number to the WWW
client
  return http_10_header & "Error " & num & ", " & msg
 end try
end handle CGI request
---------------------------------------------------------------------
To unsubscribe, mail majordomo "at" uk.research.att.com with the line:
'unsubscribe vnc-list' in the message BODY
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------