- WeirdX: http://www.jcraft.com/weirdx/
- cgi.tcl: http://expect.nist.gov/cgi.tcl/
- aewm: http://www.red-bean.com/~decklin/aewm/
- Tcl/Tk: http://www.tcl.tk/
- some web server, I use tclhttpd and/or Apache
- some web browser that runs Java, Mozilla, Netscaper, IE, etc. If running Netscape or Mozilla, you will want the Java 1.3.x or 1.4.x plugins; the supplied Java in older Netscape browsers is somewhat lacking. Go to http://java.sun.com to download the Java plugin, part of the SDK and/or JRE packages.
<PARAM NAME="weirdx.windowmode" VALUE="RootlessWM">and also comment or remove the 'exec aewm...' line near the end of tcldemo.cgi.Be sure to read the WeirdX docs; you may want to use the applet tags that use Java plugins /w Swing, and set the appropriate property values. You can also experiment with dxpc, rexec, xdmp, sound and other cool things that WeirdX supports.How to:
- You probably already have Tcl/Tk installed, if not, do so.
- Unpack WeirdX.
- Unpack, build, and install aewm, including the 'goodies' programs.
- Unpack, build, and install cgi.tcl.
- Make some directory in your web server htdocs, say 'weirdx'.
- Copy the weirdx.jar file from weirdx-1.0.xx/misc to your htdocs/weirdx.
- Cut out the sample 'index.html' below and copy to htdocs/weirdx.
- Cut out the sample 'tcldemo.cgi' below and copy to htdocs/weirdx. Make any changes to tclsh & wish versions, paths to wish, aewm, etc. This sample runs the Tcl/Tk 'widget' demo, so change to run your own application.
- Make tcldemo.cgi executable: chmod +x tcldemo.cgi.
- If needed: fudge your web server config to execute cgi out of htdocs/weirdx.
- Start your browser and point to http://your_webserver/weirdx/index.html
<html> <head> <title>WeirdX Tcl Demo</title> <body> <p> Press <a href="tcldemo.cgi">here</a> to start the Tcl/WeirdX demo. </body> </html>
tcldemo.cgi
#!/usr/local/bin/tclsh8.3 package require cgi # html to start weirdx # note that specific html samples are provided in weirdx/misc for use with # IE, or Java plugins. set weirdx_html_start { <html> <head> <title>Tcl/WeirdX 1.0</title> </head> <body> <h1>Tcl/WeirdX 1.0</h1> <hr> <applet code="com.jcraft.weirdx.WeirdX.class" archive="weirdx.jar" width="800" height="600"> <PARAM NAME="weirdx.displaynum" VALUE="2"> <PARAM NAME="weirdx.ddxwindow" VALUE="com.jcraft.weirdx.DDXWindowImp"> <PARAM NAME="weirdx.display.visual" VALUE="TrueColor16"> <PARAM NAME="weirdx.display.acl" VALUE="+"> <PARAM NAME="weirdx.display.threebutton" VALUE="yes"> <PARAM NAME="weirdx.display.width" VALUE="800"> <PARAM NAME="weirdx.display.height" VALUE="600"> </applet> <hr> } set weirdx_html_end { </body> </html> } cgi_eval { cgi_debug -on cgi_input if {![info exists env(REMOTE_ADDR)]} { cgi_body { cgi_p "You don't have an IP address. How do expect this to work?" cgi_exit } } # WeirdX defaults to display # 2, set port accordingly set ip $env(REMOTE_ADDR) set disp 2 set port [expr 6000 + $disp] # start the weirdx applet cgi_http_head { cgi_content_type text/html } cgi_puts $weirdx_html_start # wait for the X server to start accepting connections # we try to open a socket back to the browser to check for WeirdX running. cgi_puts "[cgi_nl]Starting WeirdX......" for {set max 20} {$max >= 0} {incr max -1} { after 2000 if {[catch {set sock [socket $ip $port]}] == 0} { # X is running and accepting connections, break out catch {close $sock} break } else { cgi_puts " $max" } } if {$max < 0} { cgi_p "Couldn't connect to your machine, perhaps you are behind \ a firewall/proxy or don't have Java enabled in your browser?" cgi_puts $weirdx_html_end cgi_exit } # WeirdX is running, start up application and window manager. # aewm 1.1.12 doesn't have -display option, so set env(DISPLAY) # specify aewm goodie program 'xaw-switch' so that user can switch # active windows, but not start potentially dangerous programs like xterm. # you could even xrsh the apps over to another machine to load balance. # you also may have to specify full paths to the programs you want to # start if they are not in the PATH accessable by your web server. set env(DISPLAY) $ip:$disp exec aewm -new1 xaw-switch -new2 xaw-switch -new3 xaw-switch \ < /dev/null >& /dev/null & exec wish8.3 /usr/local/lib/tk8.3/demos/widget \ < /dev/null >& /dev/null & cgi_puts "[cgi_nl] Ready, starting application." cgi_puts $weirdx_html_end } exit