Davide Simoncini
Davide Simoncini

Reputation: 75

Premature end of script headers: C++ cgi

I hope somebody can help me with this HelloWorld CGI C++ program. I'm running a Xamp server on localhost and I compiled this code in the cgi-bin folder inside /xamp. The file name is _1.exe

#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    cout <<"Content-Type: text/html\n\n";                                       

    cout << "<?xml version = \"1.0\" encoding=\"ISO-8859-1\"?>" <<endl;          
    cout <<"<!DOCTYPE html Public \"-//W3C//DTD XHTML 1.1//EN\" "<<endl;
    cout << " \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">"<<endl;

    cout <<"<html xmlns = \"http://www.w3.org.1999/xhtml\lang=\"en\" xml:lang=\"en\"\">"<<endl;
    cout <<"<head><title>Helloworld</title></head>"<<endl;                          

    cout <<"<body><h1>Hello world!!</h1></body></html>";
    return 0;
}

The executable runs from windows but if I call it from the server I get this:

Error message:
Premature end of script headers: _1.exe 

I am compiling with Netbeans and cygwin tools.

I tried also to rename the file _1.cgi

Upvotes: 1

Views: 1192

Answers (1)

Davide Simoncini
Davide Simoncini

Reputation: 75

Got it. There was a permission problem on the _1.exe.

Upvotes: 1

Related Questions