shspc - A shervlet interpreter/compiler (written in Perl).
Download the package from http://youpou.lip6.fr/queinnec/Miscellaneous/SHSPC/shspc.pl.txt and suppress the .txt extension.
Christian Queinnec <Christian.Queinnec@lip6.fr>
A ``shervlet'' is a shell server page, that is, a blend of shell and html. Shell expressions are evaluated but should appear between <?sh and ?> tags. Any character outside these tags will appear as it stands.
The present interpreter takes a .shsp file and runs it. You may alternatively compile only (with the -c option) the .shsp file and obtain (on the standard output) a .sh file that, if executed, will produce an html content.
You may instruct your web server to run automatically .shsp pages. The basic trick is that, when serving f.shsp, the webserver outputs the html produced by:
shspc.pl f.shsp
It is of course possible to pre-compile all the .shsp files into their .sh equivalent. You may do it with:
shspc.pl -c f.shsp > f.sh
When run f.sh produces the same output as shspc.pl f.shsp.
Here is a simple example of a shervlet returning the current date.
Click here to see the next shervlet running http://youpou.lip6.fr/queinnec/Miscellaneous/SHSPC/date.shsp<html><head><title>Date</title></head><body> Today is <?sh date ?> exactly. </body></html>
Often, it is better to use the Unix shebang convention:
#! /usr/bin/perl /path/leading/to/shspc.pl <html><head><title>Date</title></head><body> Today is <?sh date ?> exactly. </body></html>
So it is sufficient to tell your Apache http server, in a .htaccess file located in the directory where your server pages are:
Options ExecCGI
AddHandler cgi-script .shsp
Of course, beware that the /path/leading/to/shspc.pl should be understood by your Apache server.
This compiler was written for an internet programming lecture in order to show that blending html and language X (whatever X is) is really easy. The word ``shervlet'' is reminiscent of the words ``shell'' and ``servlets'' (Sun TM).