post data process in shell script.

This page presents a little /bin/sh shell 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 ‘’ or whatever) and installing it (don’t forget to grant exec permission), all left to do in your own scripts is to call

eval ` $*`

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 call

export DEBUG
eval ` $* 2> logfile`


<form action=”” 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 (
eval ` $*` 
mail $FORM_email < $FORM_file 
/bin/cat << END
echo Content-type: text/plain  
echo echo done. 

Don’t forget to download the code,

Adopted from

post data process in shell script.

Leave a Reply

Your email address will not be published. Required fields are marked *

Fork me on GitHub