Error - Premature end of script headers for C CGI Files
Dear All,
We are migrating an application from UNIX to RHEL-5. I am getting following error: "Premature end of script headers : : date.cgi date.cgi is an executable with source written in C Lang. Can anybody help me to resolve this error. Thanks in Advance. With Regards Pramod |
I guess you get the error from a webserver. You can check the webserver's error log for hints and also try to run the cgi from CLI and see if it produces valid HTML.
Most likely you'll need the sources to recompile it for linux. Regards |
Thanks for the reply..
I got this error in the error log file of apache server. I recompiled the file in RHEL-5. The date.cgi accepts the date and time format as parameters through http and then creates an image of date using fly (which already installed). The tool to test date.cgi using html is as follows <html><body background="NA02.GIF"> date test<br> <img src=today "date.cgi?mode=date&b1=255&b2=255&b3=255&s1=0&s2=0&s3=0&tp=bg"> </body></html> The GIF file is present in the same directory where date.cgi resides. |
What happens if you run the script directly in CLI:
Code:
/path/to/apache-cgi-bin/date.cgi?mode=date&b1=255&b2=255&b3=255&s1=0&s2=0&s3=0&tp=bg |
I have given the permission 755 and tried even 777 as well to the directory and file.
But giving the same problem. |
755 is generally OK, but in your case since you use RHEL it might be a SELinux problem, preventing the cgi to run correctly. That's why I'm telling you to run it from command line and see what it outputs. Better yet, run it as the user running apache.
|
I ran date.cgi as follows with apache user
$./date.cgi "mode=date&b1=255&b2=255&b3=255&s1=0&s2=0&s3=0&tp=bg" and I got nothing. Do you have any idea about how to debug. I tried by running gdb , but got null value for "getenv("REQUEST_METHOD")" and program exited. |
You should run it exactly as it is requested by the browser:
Code:
./date.cgi?mode=date&b1=255&b2=255&b3=255&s1=0&s2=0&s3=0&tp=bg |
It gives the the error as follows
[root@odn235 src]# ./date.cgi?mode=date&b1=255&b2=255&b3=255&s1=0&s2=0&s3=0&tp=bg& [8] 2506 [9] 2507 [10] 2508 [11] 2509 [12] 2510 [13] 2511 -bash: ./date.cgi?mode=date: No such file or directory The CGI's were running on HP - UNIX 32 bit machine. The current machine is also RHEL-32 bit machine. |
It should be better run it as the apache user. Most likely it cannot find the directory to write the image or something like that. Are you sure it's not a SELinux problem?
Could you post the code here, so someone familiar with C more than me could help? |
All times are GMT -5. The time now is 04:18 AM. |