Problems with format

Problems with the Linux version of XAMPP, questions, comments, and anything related.

Problems with format

Postby gpfdez » 21. March 2009 21:11

Hi!

I'm using cpp code to generate .cgi files. The problem is that I tried to execute a file with .cgi extension and in error log file I have this:

[Sat Mar 21 21:04:02 2009] [error] [client 127.0.0.1] (8)Error de formato ejecutable: exec of '/opt/lampp/htdocs/Ejemplos_Proyecto/PFORM/parser.cgi' failed
[Sat Mar 21 21:04:02 2009] [error] [client 127.0.0.1] Premature end of script headers: parser.cgi

The code of parser.cpp is this:

#include <iostream>
#include <malloc.h>
#include <cstdlib>
#include "cgi.h"


using namespace std;

int main()
{
CCGI cgi;
CCGIItem item;
char* lpszOut;
char* lpszContentLength = getenv("CONTENT_LENGTH");
int i,nLength;

cout << "Content-type: text/html" << endl << endl;
cout<< "<html>" << endl;
cout << "<body>" << endl;
cout << "<p>You sent " << lpszContentLength;

cout << " bytes of data, which contained the following values: </p>" << endl;
cout << "<ul>" << endl;

cgi.Load();

for(i=0; i<cgi.GetItemCount(); i++)
{
cgi.GetItem(i,&item);

nLength = item.GetNameLength();
lpszOut = (char*) malloc(nLength);
item.GetName(lpszOut,nLength);

cout << "<li>" << lpszOut << " - ";

free(lpszOut);

nLength = item.GetLength();
lpszOut = (char*) malloc(nLength);
item.GetValue(lpszOut,nLength);

cout << lpszOut << endl;

free(lpszOut);
}

cout << "</ul>" << endl
<< "</body>" << endl
<< "</html>" << endl;
return 0;
}


I hope you could help me.

Thanks a lot.
gpfdez
 
Posts: 8
Joined: 15. November 2008 17:52

Re: Problems with format

Postby Nobbie » 21. March 2009 23:54

1) Can you execute parser.cgi in shell?
2) What is the output of parser.cgi in a shell?
3) What are file permissions of parser.cgi (Ownership and permissons)?
4) How is CGI enabled in httpd.conf?
5) How is parser.cgi called/triggered in your browser?
6) How is Apache running (which user and which group?
7) What are the permissions of foldert /opt/lampp/htdocs/Ejemplos_Proyecto/PFORM/?
Nobbie
 
Posts: 8770
Joined: 09. March 2008 13:04

Re: Problems with format

Postby gpfdez » 22. March 2009 17:23

I'm going to check all these points.

Thanks! I'll tell you if I can make it work
gpfdez
 
Posts: 8
Joined: 15. November 2008 17:52


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 5 guests