MY CGI DON'T WORK, WHY?

Felipe 2010-06-18 21:57:55 Link
Hi,

I'm trying to use the simple "Hello World" as a cgi and I always get error
502 Bad Gateway
The CGI was not CGI/1.1 compliant. 

I'm able to use the default index.html and its cgis (led control for
example), but when i use my "hello world" cgi in c language and compile it,
it doesn't work.

I'm placing my cgi's and html files in the directory /www (the same of the
index.html)

here is my html:

<html>
<body>  
  <P><A HREF="helloworld.cgi">RUN helloworld.cgi</A>.</P>
</body>
</html>

and here is my c code for cgi:

void main() {
  
    printf("Content-type:text/html\n\n"); 
   
    printf("<html>\n") ;
    printf("<head><title>CGI Output</title></head>\n") ;
    printf("<body>\n") ;
    printf("<h1>Hello, world.</h1>\n") ;
    printf("</body>\n") ;
    printf("</html>\n") ;

    exit(0) ;
}

Can any one tell me how to get this to work?

Thanks.

Sharp 2010-06-20 14:36:36 Link
Hi,

Try to add read and execute acces rights to others.

chmod o+rx helloworld.cgi

Felipe 2010-06-22 13:35:13 Link
Hello Sharp.

I did what you said, and now I'm not getting the 502 error anymore.

But when I try to execute the CGI, clicking on its link in the browser, the
browser ask me to SAVE the file instead of just execute it.

I tried to use the chmod 777 to force it to become an executable but it
didn't work too.

I'm compiling it with this: gcc helloworld.c -o helloworld.cgi

I'm placing the files in the /www/ directory of my mini2440.

Could the way i'm compiling, or the location of the files be the problem?

Thanks!

Felipe 2010-06-23 15:48:21 Link
Actually I'm getting the 502 error when i try to make the cgi and html run
on arm. I tried the chmods i said before and it's still not working.

When i run it on ubuntu boa's server I don't get the 502 error, but I'm
still not able to execute the cgi file (the browser ask me to save it
instead of execute i).

Any ideas?

PS: My HTML skills are really bad...

Sharp 2010-07-06 14:56:25 Link
I think your problem is the location of the cgi files.
I use mini-httpd on my Mini as web server, and it needs to be the cgi
scripts in "cgi-bin" named folder ( you can change it in a configuration
file ).
Check out your configuration file for your web server.

Good Luck

Sharp

Felipe 2010-07-07 14:36:29 Link
Thanks again Sharp.

I solved the problem.
Apparently my problem was not the cgi's location.

After some long researchs on google i found some different c codes for a
helloworld cgi.

Basically i changed the line that was:
printf("Content-type:text/html\n\n");

for something slightly different and now it runs fine.


Thank you for all your cooperation!

Prakash James 2012-01-21 07:59:19 Link
Hi Felipe,

    Could you please share your sollution to this problem? I've been stuck
with the same issue for hours now. It would be of great help if you can
share the exact change that you made to the following line

printf("Content-type:text/html\n\n"); 

Thanks in advance!

Reply

Name
eMail (not visible)
Subject (no text only in upper case; no HELP, URGENT...)
Text
HTML tags are not supported and links are generated automatically if they start with http or ftp.
Please submit long source code or log files as attachment (only registered users).
Please enter the number 4195