1. INTRODUCTION [TOC] This document attempts to provide links to some sites which provide Bash shell scripting resources, including doing CGI scripting with the bash shell. There are those who would think that this is a ridiculous idea (and from a security point of view they may be right) but I find the Bash shell to be an effective 'prototyping' method. 2. SOME REASONABLE BASH RESOURCE SITES [TOC] [*]http://www.boutell.com/search/ A perl web-site search engine by thomas boutell who wrote the gd library. Probably knows what he's doing. Uses an index file. [*]http://dunne.dyn.dhs.org/~paul/scripts_text.html Some reasonable shell scripts, including 'exclusive delete' for sed [*]http://www.shelldorado.com/ The cgi library which this site contains is probably the most worthy of trust. The other two sites mentioned below appear distinctly hacked-up and I dont really feel that I can trust their implementation. However, this site uses a shell script library which may be slower than the c program mentioned below. Shell programming resources. A good archive of shell scripts, cgi, etc reading from standard input etc. Contains a script 'urlgetopt' which get the data posted from a form in a CGI script. An article on how to improve the efficiency (speed) of shell scripts (i.e. dont use 'cat') [*]http://www.shelldorado.com/goodcoding/cmdargs.html Using getopts example [*]http://bashlib.sourceforge.net/ A library for writing CGI scripts in the Bash shell. Actually the documentation for this small library is by no means good. There is no Debian Package available for this. In order to get this to work I had to manually copy the 'bashlib' file into the /usr/local/lib/ directory and possibly set the permissions. The installation documents mentioned vaguely about copying the 'bashlib' file somewhere but did not specify exactly where. I unpacked the download file, cd'd into the unpacked directory and ran the 'configure' script. Another gotcha is that the example script given on the web site contains an error which prevents the script from doing anything useful. The error is, I believe an unclosed echo quote string. When this was fixed the script ran. bashlib is itself a shell script which parses the querystring and post environment variables. For this reason, it would probably be slower than the c program which is refered to below (proccgi) [*]http://www.fpx.de/fp/Software/ProcCGIsh.html Shell script and C program for processing CGI form data. It is necessary to compile the c code. There is a short 'form' example but no other documentation. Appears to be no Debian package for this. I compiled the code with gcc -o proccgi proccgi.c This also was the usual cgi torment to actually get working. There were a few 'gotchas'. Firstly, the c program was named 'proccgi.c' (with two c's) however, in the 'cut-and-paste' example which the author puts on his web site the call is to a 'procgi' with only one c. Secondly, using eval "`proccgi $*`" doesnt seem to work on the 'local box' where as eval "`./proccgi $*`" does work, assuming that the proccgi file is in the same directory as the cgi file. In other words you have to include the path to the proccgi file, where ever it may be. In addition there were the usual cgi headaches of permissions. You have to do chmod a+x cgiProgramName and also apache may not allow html files in the cgi-bin directory. But in the end this program does appear to be working. The final 'gotcha' was that I was not outputting a blank line after the content type line: echo "Content-type: text/html" echo "" The HTML form values are placed in variable named FORM_parametername [*]http://heron.snell.clarkson.edu/~horn/classes/tc444/scripts/bestbash.seegi.html Bash CGI 'here document' example, and nothing else [*]http://web20013.tripod.com/webprogramming-unleashed/17.htm A basic Bash CGI tutorial. doesnt seem to cover form data. [*]http://bashish.sourceforge.net/ A 'theme' engine for bash, ie a customizer of visual elements of the shell [*]http://sourceforge.net/softwaremap/trove_list.php?form_cat=96 The CGI Tools category listing on sourceforge [*]http://txt2regex.sourceforge.net/ An engine for converting plain english into regular expressions (?) Part of Debian. displays regular expression syntax for a variety of tools, perl, awk, sed etc. This may be useful for finding 'quirks' in the syntax of a particular tools regular expressions. 3. NOTES [TOC] The most important task of a cgi library is to parse the environment variables in order to extract the HTML form values. This is why I have been searching for a decent library to allow this in a bash shell cgi environment. However there are dodgy and non-dodgy ways of parsing the variables. 4. CONTACT INFORMATION [TOC] Date: apr 2003 please send comments about this document to: matthew@ella-associates.org or matth3wbishop@yahoo.com |