Project

General

Profile

Bug #1256

CGI in C - 500 Error - cygwin

Added by Anonymous about 12 years ago. Updated about 3 years ago.

Status:
Obsolete
Priority:
Normal
Assignee:
-
Category:
core
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Missing in 1.5.x:
Yes

Description

Hi,

I am testing a simple CGI executable written in C. (NOT FCGI).

------------------------------- simple c code

#include <stdio.h>

int main(void) {
printf("content-type: text/html\n\n");
printf("cgi c\n");
return(0);
}

------------------------------- to test.xx

cc -o test.xx test.c

------------------------------- my lighttpd conf file

  1. CGI module
    cgi.assign = ( ".pl" => "/usr/bin/perl",
    ".xx" => "" )

With the above I get a 500 error

127.0.0.1 127.0.0.1 - +0000 "GET /test.xx HTTP/1.1" 500 369 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"


I am running lighthttpd 1.4.9-1 unde cygwin.

Thanks

History

#1

Updated by darix about 12 years ago

can you try:


#include <stdio.h>

int main(void)
{
  printf("Content-Type: text/plain\r\n");
  printf("\r\n\r\n");
  printf("cgi c\n");
  return(0);
}

and do you get any messages in the error log?

#2

Updated by Anonymous about 12 years ago

sorry, still the same. carriage return and newline did not make a difference


  1. CGI module
    cgi.assign = ( ".pl" => "/usr/bin/perl",
    ".cgi" => "/usr/bin/perl",
    ".xx" => "" )

#include <stdio.h>

int main(void) {
printf("Content-Type: text/plain\r\n");
printf("\r\n\r\n");
printf("cgi c\n");
return(0);
}


cc -o test.xx test.c


access.log

127.0.0.1 127.0.0.1 - +0000 "GET /test.xx HTTP/1.1" 500 369 "-" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)"


nothing in error log


#3

Updated by justinmteal about 12 years ago

i've got a similar problem with perl, but it's a less simple script than that. the script is, however less complex than another script i have that runs just fine.

access.log :

192.168.1.1 jmteal.dyndns.org - -0400 "GET /~teal/cgi-bin/percup.cgi HTTP/1.1" 500 369 "http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" "Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4"
192.168.1.1 jmteal.dyndns.org - -0400 "GET /~teal/cgi-bin/percup.cgi HTTP/1.0" 500 369 "http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" "w3m/0.5.1+cvs-1.968"

nothing in error.log

"http://jmteal.dyndns.org/~teal/scripts/percuperl/percup.html" has a link to the offending script at the bottom that will let you view the code.

What makes it weird is that if i reload a few times, it works intermittently!

any help appreciated!

#4

Updated by Anonymous about 12 years ago

it's not the same problem as my C cgi executable.

--

according to your description, your percup perl script is getting intermittent "400" response. "400" is:

10.4.1 - 400 Bad Request
The request could not be understood by the server due to malformed syntax. The client SHOULD NOT repeat the request without modifications.

--

My C cgi executable is getting a "500" response. "500" is

10.5.1 - 500 Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request.

--

#5

Updated by Anonymous about 12 years ago

no no... read the access.log. it's a 500 i'm getting. if the problem was in my script, i would assume it would never work. it just works intermittently.

#6

Updated by Anonymous about 12 years ago

weird. the first line that the script printed:

print "<DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";

same as another script that works every time. for some reason lighttpd really hated this line. every page on my site starts with that, but it kept giving me a 500 90% of the time with this script. any ideas?

-- teal.justin.m

#7

Updated by Anonymous over 11 years ago

i am getting 500 errors running a cgi binary 'hello.exe' compiled from 'hello.c' (see link below) using gcc 3.4.4 and serving on lighttpd-1.4.18 / cygwin 1.5.25 / winxpsp2 (see link below) with lighttpd.conf cgi.assign '.exe' => ""

a similar 'hello.cgi' (#!/bin/sh) bash shell script serves fine using the same configuration with lighttpd.conf cgi.assign '.cgi' => ""

ua tested were ff3.0b5 and ie7.0.5739.11. happy to do more in-depth trouble-shooting if helps.

reference

strace http://pastebin.com/f29b29978 (request for 'hello.exe')

hello.c http://pastebin.com/fa9ffd57 (source for 'hello.exe')

-- cpl160 at gmail.com

#8

Updated by stbuehler about 11 years ago

  • Status changed from New to Fixed
  • Resolution set to worksforme

There have been many changes in mod_cgi and it works for me.

Please reopen if you still have problems.

#9

Updated by stbuehler almost 11 years ago

  • Status changed from Fixed to Missing Feedback
#10

Updated by Anonymous almost 11 years ago

MS Windows 2000, Cygwin, lighttpd

Can run a CGI Perl script with .pl and .cgi extensions. Cannot run a CGI executable written in C++. Instead of executing, the browser starts downloading the executable. Filename is cgitest.exe.

$ /usr/sbin/lighttpd -v
lighttpd-1.4.20 - a light and fast webserver
Build-Date: Oct 19 2008 14:04:03

  1. CGI modules
    alias.url = ("/cgi-bin/" => "/var/www/cgi/")
    $HTTP["url"] =~ "/cgi-bin/" {
    cgi.assign = ( ".pl" => "/usr/bin/perl", ".cgi" => "", ".exe" => "", "" => "")
    }
#11

Updated by Anonymous almost 11 years ago

  • Status changed from Missing Feedback to Reopened
#12

Updated by trumor about 8 years ago

I had the same problem.

The problem was that the execute bit hasn't been set correctly. (while the read bit was set)

For example

$> ls -l test.cgi
-rwxr-xr-- 1 root root   76 17. Jun 15:18 test.cgi

After I executed

$> chmod +rx test.cgi 

everything worked.

Hope this helps.

#13

Updated by gstrauss about 3 years ago

  • Description updated (diff)
  • Missing in 1.5.x set to Yes
#14

Updated by gstrauss about 3 years ago

  • Status changed from Reopened to Obsolete

Also available in: Atom