The CERN HTTPD server comes with a useful script called cgiparse, which does most of the hard work we did above. It will work with either the GET or POST methods, though again we recommend using POST for forms of any length.
cgiparse reads the QUERY_STRING environment variable (as set if you use the GET method) or, if QUERY_STRING is not set, reads CONTENT_LENGTH characters from standard input (as set if you use the POST method). What it does next depends on which flag you give it, but for now we're only interested in the `` -form'' flag.
`` cgiparse -form'' outputs a string which, when evaluated by the Bourne shell, sets environment variables (with `` FORM_'' prepended to their names) for each of the form elements. It also URL decodes the variables for you.
Thus a script to do the same task as above (now written in Bourne shell!) would be:
#!/bin/sh eval `cgiparse -form` $filename=$FORM_pubname $doc_root="/cs/research/www/www/htdocs" $fullfilename=$doc_root"/misc/uk/london/pubs/auto-"$filename".html" #Write the entry to a file in HTML echo "<TITLE>"$FORM_pubname"</TITLE>" > $fullfilename echo "<H1>"$FORM_pubname"</H1><HR>" >> $fullfilename echo "<I>"$FORM_pubaddress"</I><P>" >> $fullfilename echo "<h2>Area:</h2> "$FORM_area"\n" >> $fullfilename echo -n "<h2>Description:</H2>" >> $fullfilename .....and so on...
cgiparse can take many other command line options to modify it's behaviour, and can be used for tasks other than form processing - we recommend the CERN httpd Reference Manual which is available on the web for a more detailed explanation.