LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-14-2009, 02:48 AM   #1
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Rep: Reputation: 15
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
 
Old 05-14-2009, 04:25 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
 
Old 05-14-2009, 04:44 AM   #3
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 05-14-2009, 05:00 AM   #4
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
Could be a permissions problem, if the cgi cannot create the image in the specified directory.
 
Old 05-14-2009, 05:18 AM   #5
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
I have given the permission 755 and tried even 777 as well to the directory and file.
But giving the same problem.
 
Old 05-14-2009, 05:37 AM   #6
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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.
 
Old 05-14-2009, 06:36 AM   #7
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 05-14-2009, 06:47 AM   #8
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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
Btw on what Unix was this cgi first running?
 
Old 05-14-2009, 07:07 AM   #9
pramod.srk
Member
 
Registered: Feb 2009
Posts: 47

Original Poster
Rep: Reputation: 15
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.
 
Old 05-14-2009, 07:38 AM   #10
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
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?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Premature end of script headers: CGI fatturi Linux - Newbie 4 07-19-2007 04:55 PM
apache and cgi problem. Premature end of script headers. JAdj Linux - Software 1 10-25-2006 03:45 AM
python cgi script and premature end of script headers Neruocomp Programming 1 07-28-2005 11:43 AM
Perl/CGI Problem "Premature Premature end of script headers: countdown.pl" newuser455 Linux - Software 2 07-18-2004 11:47 AM
Premature End of Script Headers (Error 500) bsdb3 Red Hat 5 05-06-2004 11:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 04:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration