Making a shell-based W3 server

A Shell Server for HTTP

The HTTP protocol is very simple. The following is an example of a server program written in sh:
#! /bin/sh
read get docid
echo "<TITLE>$docid</TITLE>"
echo Here is the data

The docid may have a trailing carriage return to be stripped off on some systems. You can modify that script to produce the data you actually want. The HTML syntax for marked-up text is fairly simple, but if you want just to send plain text, then just send the .PLAINTEXT.tag first:
#! /bin/sh
read get docid
sed -f txt2html.sed $docid

or in csh
#! /bin/csh
request = ( `echo $<`)
if ($#request <2) exit
sed -f txt2html.sed $request[2]


When you have written your script, set the execute bit and then configure the inet daemon to run it . A few more examples: If you know the perl language, then that is a powerful (if otherwise incomprehensible) language with which to hack together a server.

See also a case study of mapping a database onto the web .

All contributions to these examples welcome!

Tim BL