3q
What is 3q?
3q is a CGI script that executes awk code that is embedded into HTML files on your web server. To be more precise 3q
- expects XML formatted files. You don't need to use an XML editor, HTML files where every tag is properly closed are accepted, <some-tag/> is supported.
- awk code is placed inside a `<? awk ... ?>' processing instruction. The `awk' keyword is required.
- The awk code is limited to code that can be placed in a BEGIN block which excludes user functions.
- User functions can be placed in library files that can be #use'd from the 3q file.
How is this working?
3q is itself an awk script so there must be a trick. First 3q reads the XML file and converts this into a gawk script, static HTML/XML text is converted in printf() calls and source code inside <? awk ... ?> is passed as is. The resulting script code is then passed to a second gawk invocation as command line script. 3q relies heavily on proper shell quoting.
This idea is not new. Recently I found SQAwk on Sourceforge: http://sourceforge.net/projects/sqawk/. The basic principle is the same (quoting then executing) but for some reason this project was abandoned.
Download the script: 3q.
Limitations
- The total length of the executed gawk script and passed CGI variables depends on limitations of the shell interpreter regarding the command line length.
- 3q uses "expensive" (in terms of CPU time) system calls to stat() files and for script execution.
Available Documentation
Just some notes here.