Version 9 of WiKit under CGI

Updated 2002-06-29 23:41:43

WiKit and TclKit were designed to run out-of-the-box, with no installation or configuration whatsoever. The installation is just like for local use, but you will need to work around the limited permissions provided by some web servers.

There are two issues:

  1. Where to put the WiKit file and how to let it find TclKit.
  2. Accesssing and altering the database embedded in WiKit.

mh: Accessing wikit works fine from Apache if done carefully and slowly, but if (apparently) two copies try to run at the same time, an error 500 is returned and this shows up in the apache log:

  [error] (26)Text file busy: exec of /ap/htdocs/wikit.dvp failed
  [error] [...] Premature end of script headers: /ap/htdocs/wikit.dvp

Any ideas?


If your server does not let you run scripts under your own ID:

  • Make sure the WiKit file is executable and writable by all: chmod a+rwx wikit.tkd
  • Make sure WiKit is allowed to create a lockfile next to it (called wikit.lock)

If your server requires CGI scripts to end in ".cgi":

  • Just rename "wikit.tkd" to wikit.cgi, since WiKit will work under any name

If your script doesn't work because it can't find TclKit:

  • You'll have to write a small wrapper. Here's a "wikit.cgi" script which worked for me:
        #!/bin/sh
        exec /home/jcw/bin/tclkit /home/jcw/wikit/wikit.tkd

If you're wondering how WiKit can act as both a CGI script and as a Tk GUI app: what it does is look for an environment variable called "SCRIPT_NAME". If present, it proceeds as a CGI process, else it turns itself into a Tk GUI application.


DGR - I'm am not familiar with CGI usage. I would like to run WiKit on my own windoze pc under Netscape. I think I need to learn about ServerBasics. I do have WiKit running under TclKit and it works great.


LV - 2001-Feb-08 - I am trying to get a Wikit up and running under a new environment (Solaris 8, Netscape Enterprise Server, etc.). I have followed the instructions on this page. The server reports this error when I try to start up the cgi:

 [[22/Sep/2000:11:45:48]] failure (28486): for host 134.243.55.72 trying  to GET /~lwv26/cgi-bin/wikit.cgi, cgieng_scan_headers reports: the CGI  program /home/lwv26/castest_html/cgi-bin/wikit.cgi did not produce a  valid header (name without value: got line "unable to alloc -5868  bytes")

Could someone assist me in getting this to work? I've been trying, pretty much unsuccessfully, for more than a year.


Anyone know why a Linux box would generate:

 Mon May 28 15:15:48 2001] [error] [client 192.168.1.71] Premature end of script headers: /export/home/gershom/public_html/cgi-bin/wikit.cgi
 application-specific initialization failed: /usr/tmp/tclkit not owned by
 /usr/tmp/tclkit not owned by
    while executing
 "error "$temp not owned by $user""
    (in namespace eval "::vfs" script line 30)
    invoked from within
 "namespace eval ::vfs {
    variable debug      0
    if {[info exists env(VFS_DEBUG)]} {
        set debug $env(VFS_DEBUG)
    }

    variable fstab
    variable ..."
    ("uplevel" body line 58)
    invoked from within
 "uplevel #0 $s"
    (procedure "tclInit" line 68)
    invoked from within
 "tclInit"
 [Mon May 28 15:17:50 2001] [error] [client 192.168.1.71] Premature end of script headers: /export/home/gershom/public_html/cgi-bin/wikit.cgi

/usr/tmp is a link to /var/tmp. And my UID does own /var/tmp/tclkit. I used the script above, and other cgi scripts work in that directory. It runs in local mode.

JCW: Oops, this is my fault... I accidentally released a build of TclKit (8.4-22) which has a problem with shared-lib loading. Please update to a newer build of TclKit (see [L1 ]).

lh That was it. Thanks! (Do we need to cut out some/all of the above?)


Short instructions for runninng a CGI Wikit on linux/apache.

1. Download the Wikit [L2 ].

2. Download the proper TclKit [L3 ] 8.4-23 seems the most current as of 29 May 01.

3. Put both into your $HOME/public_html/cgi-bin directory; or whereever the "UserDir" puts personal web pages. Mine "UserDir" is defined in srm.conf.

4. Change the names, tclkit.bin to tclkit, wikit.bin to wikit.tkd.

5. See the above note about the wikit.cgi shell wrapper.

6. Set the permissions to ???

7. Make sure your webserver can serve cgi pages. This includes the "ExecCGI" in access.conf

8. Restart the web server.

9. Make sure you have a web server running. ps -ef | grep httpd should show several lines of httpd.

10. View the page as http://{server}:{port}/~{username}/cgi-bin/wikit.cgi

11. If there are problems, read the error_log file. Mine is in /etc/httpd/logs.

12. Deeper Apache information [L4 ].


If http://server:port/dir/cgi-bin/wikit.cgi brings up a page where none of the links appear to work, try instead http://server:port/dir/cgi-bin/wikit.cgi/ -- the trailing slash apparently can be important.


May 9, 2002 - There is a new version of wikit, see the WiKit home page at [L5 ]. It differs from the previous code in that it keeps the wiki data in a separate MetaKit datafile, while the code is now a standard scripted document. This is not a rewrite, but it does consolidate all the latest changes, clean up lots of internal messiness, and it's much easier to alter without losing existing wikit page contents. This version can in fact be used alongside an existing "wikit.tkd" file, and manage the pages in it while ignoring the original scripts stored in wikit.tkd ...

This code will be used for the Tcl'ers Wiki itself real soon (just a bit more tweaking, testing, and a few more changes) -JCW


Any new instructions for getting the new version of wikit running under CGI? I'm getting the "Premature end of script headers" error message. I'm running Apache/1.3.20 Server and have "Hello World" type CGI scripts working fine.

One reason wikit can fail, is when the file is not writable when called as CGI, i.e. if this is not the same uid then you better make the datafile writable for all, and also the directory it lives in so the lock file can be created and removed -jcw


Category Wikit