Run cygwin executable as CGI

This is a discussion on Run cygwin executable as CGI within the Apache Web Server forums, part of the Web Server and Related Forums category; Hi, I would like to be able to execute a binary compiled with cygwin as CGI *with Apache 2.2....


Go Back   Usenet Forums > Web Server and Related Forums > Apache Web Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-18-2007
ken
 
Posts: n/a
Default Run cygwin executable as CGI

Hi,

I would like to be able to execute a binary compiled with cygwin as CGI
*with Apache 2.2.4 for windows*.

I already updated the httpd.conf of the web server so that all .exe are
properly managed as CGI scripts. So for the moment, the following
program compiled with Visual .NET works as expected:

--------------------------------------------------------------------
#include <stdio.h>

int main()
{
printf("Content-type: text/html; charset=iso-8859-1\n\n");
printf("<html><body>Hello World!\n</body></html>");
return 0;
}
--------------------------------------------------------------------


However if I run those compiled under cygwin environment with gcc, I
got the following Apache error log entry when I try to execute it:
[Thu Jan 18 14:34:50 2007] [error] [client 129.73.8.72] Premature end
of script headers: foo.exe

I changed the `LogLevel' to `debug' in the `httpd.conf' but it doesn't
provide more information about what is going on.

I guess it's because of the cygwin required libraries. But I copied the
required `zlib1.dll' and `cygz.dll' files in C:/WINDOWS to be able to
run the cygwin binaries from the windows command line. I suppose that
the Apache child process has a smaller environment so I copied the 2
cygwin DLL in C:\Program Files\Apache Software Foundation\Apache2.2\bin
but nothing better....

I wrote a small shell script to try to understand what is going on in
the child process, here it is:

--------------------------------------------------------------------
#!c:/cygwin/bin/sh.exe
##
## debug.sh
##

echo -e "Content-type: text/plain; charset=iso-8859-1\n\n"

env

echo
echo
echo "Cygwin Location of foo: "
ls -l $PWD/foo
../foo
echo "Return value: $?"
echo
echo "Another try but with the windows path
(c:/cygwin/opt/www/cgi-bin/foo):"
c:/cygwin/opt/www/cgi-bin/foo
echo "Return value: $?"
echo
echo "Another try but with windows interpreter:"
cmd /C "c:\cygwin\opt/www\cgi-bin\foo.exe"
echo "Return value: $?"
--------------------------------------------------------------------

and here is the output when run as CGI script:
--------------------------------------------------------------------
SERVER_SIGNATURE=
TERM=cygwin
WINDIR=C:\WINDOWS
HTTP_X_FORWARDED_FOR=XXX.XXX.XXX.XXX
HTTP_USER_AGENT=Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1
SERVER_PORT=80
HTTP_HOST=XXXXXX
DOCUMENT_ROOT=C:/Program Files/Apache Software
Foundation/Apache2.2/htdocs
HTTP_ACCEPT_CHARSET=ISO-8859-1,utf-8;q=0.7,*;q=0.7
SCRIPT_FILENAME=C:/cygwin/opt/www/cgi-bin/debug.sh
REQUEST_URI=/bin/debug.sh
SCRIPT_NAME=/bin/debug.sh
HTTP_VIA=1.1 proxy (NetCache NetApp/6.0.3)
HTTP_CONNECTION=keep-alive
REMOTE_PORT=19717
PATH=/opt/www/bin:/usr/bin:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:
PWD=/opt/www/cgi-bin
SERVER_ADMIN=XXXXXXX@XXXXX
HTTP_ACCEPT_LANGUAGE=en-us,en;q=0.5
HTTP_ACCEPT=text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
REMOTE_ADDR=XXX.XXX.XXX.XXX
SHLVL=1
HOME=/
SERVER_NAME=XXXXX
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WS F;.WSH
COMSPEC=C:\WINDOWS\system32\cmd.exe
SERVER_SOFTWARE=Apache/2.2.4 (Win32)
SYSTEMROOT=C:\WINDOWS
QUERY_STRING=
SERVER_ADDR=XXX.XXX.XXX.XXX
GATEWAY_INTERFACE=CGI/1.1
SERVER_PROTOCOL=HTTP/1.1
HTTP_CACHE_CONTROL=max-age=0
HTTP_ACCEPT_ENCODING=gzip,deflate
REQUEST_METHOD=GET
_=/usr/bin/env


Cygwin Location of foo:
-rwxr-xr-x 1 tristan ???????? 8873 Jan 18 14:34 /opt/www/cgi-bin/foo
Return value: 34

Another try but with the windows path (c:/cygwin/opt/www/cgi-bin/foo):
Return value: 34

Another try but with windows interpreter:
Return value: 34
--------------------------------------------------------------------

The errno of 34 is:
#define ERANGE 34 /* Math result not representable */
so I guess it does not refer to this ... and I can't find another
clue...


So if you have already encountered this problem ... I would be glad
that you share your experience. I know a little bit about apache, so
maybe there is a way to have more details about why the child process.

Thank you by advance
--
Tristan Carel

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:35 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0