Chad,
firstly, thank you very much for taking the time to respond in such detail.
About the script, it's stored in MySQL on a linux server.
The file is being generated on a secure port which runs with sudo to execute commands not permitted by anyone but root. (Had to go that route for user manager options and qmail functions).
The operation proceeds in the following way :
Script code is called from MySQL
Script is written to file
File permission is changed to 755
File ownership is given to client
File is moved to client's cgi-bin
When I check the file : all operations are successful. The mode is 755, the owner is the client.
About specific questions you had :
Does the script contain the 'print "Content-type: text/html\n\n";
Yes. It's actually the popular FormMail.pl script written by Matt Wright. (http://www.worldwidemart.com/scripts/)
Is there an error message before the 'premature end..' message and what is it?
Only error message :
[error] [client IP_ADDR] Premature end of script headers: /path/to/perl_file.pl
Maybe make sure the "Content-Type" header is printed in the beginning of the script so that if the script is erroring out, you will get the message in the browser.
I do not get this message in the browser.
The source for the 500 error is :
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<HEAD>
<TITLE>500 Internal Server Error</TITLE>
</HEAD><BODY>
<H1>Internal Server Error</H1>
The server encountered an internal error or
misconfiguration and was unable to complete
your request.<P>
Please contact the server administrator,
admin@address and inform them of the time the error occurred,
and anything you might have done that may have
caused the error.<P>
More information about this error may be available
in the server error log.<P>
<HR>
<ADDRESS>Apache/1.3.17 Server at vhostdomain.com Port 80</ADDRESS>
</BODY>
Also,
perl -c script.pl says Syntax OK
perl -e script.pl says nothing
How was the file placed in the database?
PhpMyAdmin - pasted it into the text field.
Right now I am moving on to looking for a way to execute pico and make a small change (control+k, control+u) to the file and saving/exiting out. Not the best way - but maybe it'll work.
Unfortunately I don't know how to send Control+X via popen, but that's a small issue right 🙂
Again, thank you for your response.
I'll keep digging, and if I come across a fix, I'll be sure to share it here.
Best Regards,
-m.