A 500 error on a script usually means there is a syntax error. There are two good ways to debug a script.
You can first check your error log located in the stats section of the cpanel. The second way is to log into your shell and move to the directory the script is in. When in the proper directory type ./filename.cgi - This will tell you what and where the error is.