/bin/shshell script that will help you processing form data in a CGI shell script, without needing C or perl. You receive the form values straight into your shell environment, where you can then access them just like other shell variables. About no special requirements are needed, it just uses the standard Unix utilities dd, test, grep, cut, dc and echo. The latter must be able to print arbitrary octal codes.
After downloading the script (with a name of ‘proccgi.sh’ or whatever) and installing it (don’t forget to grant exec permission), all left to do in your own scripts is to call
eval `proccgi.sh $*`
In some cases, you might need to give the full pathname if it’s not found automatically. After this call, you have everything in your shell.
If something goes wrong, you can also enable some debugging output by setting the variable DEBUG to 1, causing a log to be printed to standard error. To get a debugging logfile, you would callDEBUG=1
eval `proccgi.sh $* 2> logfile`
Example<form action=”mailer.sh” method=”post”> <dl> <dt> Your Email <dd> <input name=”email” size=”50″> <dt> Filename <dd> <input name=”file” size=”50″> </dl> <input type=”submit” value=”Submit”> </form>
The script (mailer.sh)
#!/bin/sh eval `proccgi.sh $*` mail $FORM_email < $FORM_file /bin/cat << END echo Content-type: text/plain echo echo done. END
Don’t forget to download the code, proccgi.sh.
Adopted from http://www.fpx.de