cgi web app gives "premature end of script headers" but it"s there

cgi web app gives "premature end of script headers" but it"s there

am 22.04.2008 21:07:01 von drhowarddrfine

To get back to basics from a thread I entered elsewhere, I just tried
to access a small C program that does nothing but create an empty web
page. I put it in cgi-bin and give that folder and the app 755
permissions. When I access mysite.com/cgi-bin/myapp, I get a 500
internal server error and the error log says: "Premature end of script
headers: /home/rbelics/public_html/cgi-bin/test".

However, run locally on the command line, the output is correct:
Content-type: text/html; charset=utf-8

TR/html4/strict.dtd"><br /> <br /> The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> <br /> Am I missing something?</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 22.04.2008 23:55:28 von usenetpersongerryt</span> <p>On Apr 22, 12:07 pm, drhowarddrfine <robbel...@gmail.com> wrote:<br /> > To get back to basics from a thread I entered elsewhere, I just tried<br /> > to access a small C program that does nothing but create an empty web<br /> > page. I put it in cgi-bin and give that folder and the app 755<br /> > permissions. When I access mysite.com/cgi-bin/myapp, I get a 500<br /> > internal server error and the error log says: "Premature end of script<br /> > headers: /home/rbelics/public_html/cgi-bin/test".<br /> > However, run locally on the command line, the output is correct:<br /> > Content-type: text/html; charset=utf-8<br /> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/<br /> > TR/html4/strict.dtd"><html><head><title><br /> > The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> > Am I missing something?<br /> <br /> Perhaps your push cart ran outa gas?? Then again this comes up over<br /> and<br /> over when someone embeds ^M characters in a cgi by using a M$ editor<br /> to create it in the first place. It works on command line but Apache<br /> sees<br /> ^M and bales. Perhaps Dr. Curly could perform an operation...</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s there</h2><span>am 23.04.2008 00:42:13 von Felix Saphir</span> <p>usenetpersongerryt@gmail.com wrote:<br /> <br /> > On Apr 22, 12:07 pm, drhowarddrfine <robbel...@gmail.com> wrote:<br /> >> To get back to basics from a thread I entered elsewhere, I just tried<br /> >> to access a small C program that does nothing but create an empty web<br /> >> page. I put it in cgi-bin and give that folder and the app 755<br /> >> permissions. When I access mysite.com/cgi-bin/myapp, I get a 500<br /> >> internal server error and the error log says: "Premature end of<br /> >> script headers: /home/rbelics/public_html/cgi-bin/test".<br /> >> However, run locally on the command line, the output is correct:<br /> >> Content-type: text/html; charset=utf-8<br /> >> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/<br /> >> TR/html4/strict.dtd"><html><head><title><br /> >> The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> >> Am I missing something?<br /> > <br /> > Perhaps your push cart ran outa gas?? Then again this comes up over<br /> > and<br /> > over when someone embeds ^M characters in a cgi by using a M$ editor<br /> > to create it in the first place. It works on command line but Apache<br /> > sees ^M and bales. Perhaps Dr. Curly could perform an operation...<br /> <br /> Yes. Sure. He uses notepad.exe and then sets file permissions to 0755 on<br /> a file in /home/rbelics/public_html/... Sounds reasonable.<br /> <br /> Felix</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s there</h2><span>am 23.04.2008 00:46:46 von Felix Saphir</span> <p>drhowarddrfine wrote:<br /> <br /> > To get back to basics from a thread I entered elsewhere, I just tried<br /> > to access a small C program that does nothing but create an empty web<br /> > page. I put it in cgi-bin and give that folder and the app 755<br /> > permissions. When I access mysite.com/cgi-bin/myapp, I get a 500<br /> > internal server error and the error log says: "Premature end of script<br /> > headers: /home/rbelics/public_html/cgi-bin/test".<br /> > <br /> > However, run locally on the command line, the output is correct:<br /> > Content-type: text/html; charset=utf-8<br /> > <br /> > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/<br /> > TR/html4/strict.dtd"><html><head><title><br /> > <br /> > The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> > <br /> > Am I missing something?<br /> <br /> Perhaps: Who's the owner of that compiled C program? If you're owner and<br /> the permissions are set to 0755, then the apache user (perhaps wwwrun?)<br /> won't be allowed to execute the program. Does it work after chmod 0777?<br /> <br /> Felix</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 01:14:32 von drhowarddrfine</span> <p>On Apr 22, 5:46 pm, Felix Saphir <dasr060-use...@yahoo.de> wrote:<br /> > drhowarddrfine wrote:<br /> > > To get back to basics from a thread I entered elsewhere, I just tried<br /> > > to access a small C program that does nothing but create an empty web<br /> > > page. I put it in cgi-bin and give that folder and the app 755<br /> > > permissions. When I access mysite.com/cgi-bin/myapp, I get a 500<br /> > > internal server error and the error log says: "Premature end of script<br /> > > headers: /home/rbelics/public_html/cgi-bin/test".<br /> ><br /> > > However, run locally on the command line, the output is correct:<br /> > > Content-type: text/html; charset=utf-8<br /> ><br /> > > <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/<br /> > > TR/html4/strict.dtd"><html><head><title><br /> ><br /> > > The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> ><br /> > > Am I missing something?<br /> ><br /> > Perhaps: Who's the owner of that compiled C program? If you're owner and<br /> > the permissions are set to 0755, then the apache user (perhaps wwwrun?)<br /> > won't be allowed to execute the program. Does it work after chmod 0777?<br /> ><br /> > Felix<br /> <br /> Changing it to 777 didn't do anything. I should say that I'm on a<br /> shared host system and not my own.<br /> That's a question I have about ownership. The static html files are<br /> accessed, though. Were uploaded the same way.<br /> <br /> I compiled this little program on FreeBSD but it's a Linux platform.<br /> Could that have anything to do with it? All it is is a series of<br /> printfs to stdout.</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 01:15:52 von usenetpersongerryt</span> <p>On Apr 22, 3:42 pm, Felix Saphir <dasr060-use...@yahoo.de> wrote:<br /> > usenetpersonger...@gmail.com wrote:<br /> > > On Apr 22, 12:07 pm, drhowarddrfine <robbel...@gmail.com> wrote:<br /> > >> To get back to basics from a thread I entered elsewhere, I just tried<br /> > >> to access a small C program that does nothing but create an empty web<br /> > >> page. I put it in cgi-bin and give that folder and the app 755<br /> > >> permissions. When I access mysite.com/cgi-bin/myapp, I get a 500<br /> > >> internal server error and the error log says: "Premature end of<br /> > >> script headers: /home/rbelics/public_html/cgi-bin/test".<br /> > >> However, run locally on the command line, the output is correct:<br /> > >> Content-type: text/html; charset=utf-8<br /> > >> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/<br /> > >> TR/html4/strict.dtd"><html><head><title><br /> > >> The only thing in the cgi-bin .htaccess file is "Options ExecCGI"<br /> > >> Am I missing something?<br /> > > Perhaps your push cart ran outa gas?? Then again this comes up over and<br /> > > over when someone embeds ^M characters in a cgi by using a M$ editor<br /> > > to create it in the first place. It works on command line but Apache<br /> > > sees ^M and bales. Perhaps Dr. Curly could perform an operation...<br /> > Yes. Sure. He uses notepad.exe and then sets file permissions to 0755 on<br /> > a file in /home/rbelics/public_html/... Sounds reasonable.<br /> <br /> I re-read the post and...<br /> Only if the cgi is a script. If its compiled C then no. It could be an<br /> suexec<br /> problem too. And that should be DrHowardDrFineDrHoward. There were 3<br /> Stooges.</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 01:25:03 von drhowarddrfine</span> <p>And that should be DrHowardDrFineDrHoward. There were 3<br /> > Stooges.<br /> <br /> Forums truncate too often.</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 01:37:44 von usenetpersongerryt</span> <p>On Apr 22, 4:25 pm, drhowarddrfine <robbel...@gmail.com> wrote:<br /> > And that should be DrHowardDrFineDrHoward. There were 3 Stooges.<br /> > Forums truncate too often.<br /> <br /> Now that we've established that universe is flawed, the origiinal<br /> question<br /> remains... You are attempting to run a cgi in a user directory. As I<br /> recall<br /> suexec must or at least should be enabled for this to work, compiled<br /> binary or script.<br /> The log message may be misleading you.</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 01:47:22 von drhowarddrfine</span> <p>On Apr 22, 6:37 pm, usenetpersonger...@gmail.com wrote:<br /> > On Apr 22, 4:25 pm, drhowarddrfine <robbel...@gmail.com> wrote:<br /> ><br /> > > And that should be DrHowardDrFineDrHoward. There were 3 Stooges.<br /> > > Forums truncate too often.<br /> ><br /> > Now that we've established that universe is flawed, the origiinal<br /> > question<br /> > remains... You are attempting to run a cgi in a user directory. As I<br /> > recall<br /> > suexec must or at least should be enabled for this to work, compiled<br /> > binary or script.<br /> > The log message may be misleading you.<br /> <br /> I've read elsewhere that might have something to do with it. I'll<br /> pass that along as I finally decided to contact the sysadmins to see<br /> if they can see what's happening. I get the feeling that, unless it's<br /> PHP, they don't know.</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 04:59:18 von drhowarddrfine</span> <p>Well, it's more complicated than I thought. I compile the app on<br /> FreeBSD but one of the libraries doesn't exist on Linux. I haven't<br /> thoroughly looked into it but I have to find a way to make this more<br /> standalone.<br /> <br /> Thanks guys.<br /> Doc</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s there</h2><span>am 23.04.2008 10:31:53 von Felix Saphir</span> <p>drhowarddrfine wrote:<br /> > On Apr 22, 5:46 pm, Felix Saphir <dasr060-use...@yahoo.de> wrote:<br /> >> drhowarddrfine wrote:<br /> >>> [small C program as cgi, chmod 0755, gives error 500]<br /> >> [permissions okay? chmod 0777?]<br /> > <br /> > Changing it to 777 didn't do anything. I should say that I'm on a<br /> > shared host system and not my own. That's a question I have about<br /> > ownership. The static html files are accessed, though. Were uploaded<br /> > the same way. <br /> > <br /> > I compiled this little program on FreeBSD but it's a Linux platform.<br /> > Could that have anything to do with it? All it is is a series of<br /> > printfs to stdout.<br /> <br /> Sorry, I'm not an expert with C across different platforms, but it might<br /> help to link the libraries statically (heard that somewhere :) ). Is<br /> the architecture on both systems the same (like x86)?<br /> <br /> Felix</p> </article> <article> <h2>Re: cgi web app gives "premature end of script headers" but it"s</h2><span>am 23.04.2008 14:17:48 von drhowarddrfine</span> <p>On Apr 23, 3:31 am, Felix Saphir <dasr060-use...@yahoo.de> wrote:<br /> > drhowarddrfine wrote:<br /> > > On Apr 22, 5:46 pm, Felix Saphir <dasr060-use...@yahoo.de> wrote:<br /> > >> drhowarddrfine wrote:<br /> > >>> [small C program as cgi, chmod 0755, gives error 500]<br /> > >> [permissions okay? chmod 0777?]<br /> ><br /> > > Changing it to 777 didn't do anything. I should say that I'm on a<br /> > > shared host system and not my own. That's a question I have about<br /> > > ownership. The static html files are accessed, though. Were uploaded<br /> > > the same way.<br /> ><br /> > > I compiled this little program on FreeBSD but it's a Linux platform.<br /> > > Could that have anything to do with it? All it is is a series of<br /> > > printfs to stdout.<br /> ><br /> > Sorry, I'm not an expert with C across different platforms, but it might<br /> > help to link the libraries statically (heard that somewhere :) ). Is<br /> > the architecture on both systems the same (like x86)?<br /> ><br /> > Felix<br /> <br /> Yes, they're both x86. I briefly attempted static linking before I<br /> went to bed. Uploaded it and it still failed but I may not have<br /> compiled it correctly. I have to wake up and dig around on this.</p> </article> <footer> <a href="/">Index</a> | <a href="/impressum.php">Impressum</a> | <a href="/datenschutz.php">Datenschutz</a> | <a href="https://www.xodox.de/">XODOX</a> </footer> </main> </body> </html>