WN home page

Version 2.0.0
[Up] [Top]

WN Server Side Includes that Execute a Program


Is it possible to do a server-side include such as the following:

<!-- #echo var="LAST_MODIFIED" -->

I've tried it numerous ways and failed every time -- so I figured it was time for a definitive answer. I can certainly live without them but they would be nice to have.

1 How it Works

This is done with a server side include that executes a program. To see this example in action try index.html.

Here is an example of how to use scripts as server side includes. This is not a CGI/1.1 program, but something similar could be done with CGI/1.1. Assuming that the program "counter.cgi" is in the same directory as "foo.html" put something like:

File=foo.html
Includes=!counter.cgi

in your index file. Then put:

<!-- #include -->

on a line with no leading whitespace in the file foo.html. The program counter.cgi gives the current count of accesses to this page and also prints the last-modified date. It should be easy to modify for your needs.

There are a couple of permissions issues. The user id under which the server runs (e.g. "nobody") must have permission to execute counter.cgi and to read and write the file /tmp/wncount.

2 The Program counter.cgi

Here is the perl program:

        
      

WN version 2.0.0
Copyright © 1998 John Franks <john@math.nwu.edu>
licensed under the GNU General Public License
last-modified: Sun, 10 May 1998 18:07:18 GMT
[Up] [Top]