Link to home
Start Free TrialLog in
Avatar of dmontgom
dmontgom

asked on

Trying to get c++ cgi script to work in Ubuntu Apache2

Hi,
I am new to Ubuntu.  My python cgi-scripts work but my c++ cgi does not.  How do I fix?
\
  In the apache error logs I get premature end of headers error.  
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log



Below is my simple cgi script.  I also did a chmod a+x and 755.  In the http.conf file I have

ScriptAlias /cgi-bin /usr/lib/cgi-bin/
<Directory /usr/lib/cgi-bin>
    Options +ExecCGI
    Order allow,deny
    Allow from all
    AddHandler cgi-script cgi o py
</Directory>


#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <vector>
#include <string>
#include <time.h>
#include <malloc.h>

using namespace std;


int main() {

      cout << "content-type: text/html" << endl << endl;
      cout << "<html>" << endl;
      cout << "</html>" << endl;


      //cout   << "Hello! You sent " << lpszContentLength << " bytes of data which read: <br>" << endl;

      return 0;
}
Avatar of DalHorinek
DalHorinek
Flag of Czechia image

What is in error log?
Avatar of dmontgom
dmontgom

ASKER

Here the error log

[Sun Sep 12 18:33:09 2010] [error] (8)Exec format error: exec of '/usr/lib/cgi-bin/cpp_post_test.o' failed
[Sun Sep 12 18:33:09 2010] [error] [client 127.0.0.1] Premature end of script headers: cpp_post_test.o
ASKER CERTIFIED SOLUTION
Avatar of jkr
jkr
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Good job!

Thanks