Problem:
Browser displays HTTP:500 - The website cannot display the page when submitting a form and running a script in cgi-bin.
(8)Exec format error logged in $ErrorLog/error_log
Resolution:
This happens because Apache expects to run an executable and finds a script. You need to add a #! to the top of the script to tell UNIX to execute that script using the interpreter specified.
for example:
#! /bin/sh