Unable to execute a simple Win32 CGI script on Apache 2.0.35
Jay Turberville 17 April 2002 11:03:35
I'm pretty new to running a web server. My first and current dabbling has been to use Lil' HTTP which is a very simple and easy to use web server for Win32 OSes. I have a site for family, friends etc. at http://www.jayandwanda.com. Lil' HTTP has limited CGI and SSI capability and I have a simple timestamp and counter on the main site page. These CGI scripts are Win32 executables and are called in this manner: <!-- #exec cgi="datetime.cgi?time12" -->.
As I understand it, the webserver executes the Win32 executable "datetime.cgi" and that executable outputs the current system time to the webserver. The webserver then updates the calling page with the output from "datetime.cgi". Very simple and neat.
For a number of reasons I would like to move the site over to Apache. So I've got an initial install of Apache 2.0.35 running on a different machine serving pages duplicated from my active site. (I'm just using an internal network IP address for now.) However, I can't get these simple Win32 CGI "scripts" (actually Win32 executables) to run. I've gone through the online documentation and as far as I can tell I have properly included the "Includes" and "ExecCGI" options. As a test, I have tried to do an <!-- #exec cmd= "dir" -->... command from one of my pages as well and I get the same "no response." The displayed page simples shows some whitespace where the response should be and I see the original CGI command or white space on the page when I do a "view source".
in the page as shown in the Apache 2.0 docs pages, I get a proper response displayed on my page. I conclude then that my Option Include is not the problem? I'm guessing the problem must be elsewhere.
I'm probably missing something simple and obvious. I admit I am unfamiliar (being a newbie and all) with editing the httpd.conf file, but it really doesn't seem like rocket science. I have placed my current hpptd.conf file on my anonymous ftp server at: ftp://jayandwanda.com in case that would be of any help to anyone wishing to help.
I understand that most Apache users are implementing CGI with Perl. Perhaps I should just skip the Win32 CGI script and jump right to Perl? I would do that, but I hate to go forward with a fundamental misunderstanding about what is going on. Besides, the "exec cmd" is basic and should work. Right? Or perhaps I would be wiser starting out with Apache 1.3?
Any help is appreciated. Thanks.
Jay
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org
----- Original Message ----- From: "Jay Turberville" <jay@studio522.com> Date: Monday, April 15, 2002 8:56 am Subject: Unable to execute a simple Win32 CGI script on Apache 2.0.35
file, but it really doesn't seem like rocket science. I have placed> my current hpptd.conf file on my anonymous ftp server at:> ftp://jayandwanda.com in case that would be of any help to anyone> wishing to help.>
I understand that most Apache users are implementing CGI> with Perl. Perhaps I should just skip the Win32 CGI script> and jump right to Perl? I would do that, but I hate to go> forward with a fundamental misunderstanding about what is going on.> Besides, the "exec cmd" is basic and should work. Right? Or perhaps> I would be wiser starting out with Apache 1.3?>
Any help is appreciated. Thanks.>
Jay
your httpd.conf looks ok although I'd not add a + before Includes (and not before ExecCGI). Try to execute your cgi from C:/Program Files/Apache Group/Apache2/cgi-bin/ and test the script printenv.pl See also the list archive for questions around CGI with Apache2 Win _ ___ | | Irmund Thum | | +49 7031 468-2863
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org
Jay Turberville 15 April 2002 18:35:13 [ permanent link ]
OK - I've removed the +, but that (as I'm sure you figured) doesn't improve anything.
I need to install Perl first in order to run the printenv.pl script. I guess that will be my first order of business later tonight when I can look at this again.
I have searched the web and the list archives. On the web, it seems like most of what I have found is basic. Righ now it looks like I have the basics covered. Frankly, many of the responses I found in the list archive were either "program a patch" solutions that were fairly old and/or completely over my head. I'll try refining my search and keep looking.
Thanks for you help.
Jay
your httpd.conf looks ok although I'd not add a + before Includes (and> not before ExecCGI).> Try to execute your cgi from> C:/Program Files/Apache Group/Apache2/cgi-bin/> and test the script printenv.pl> See also the list archive for questions around CGI with Apache2 Win> _ ___> | | Irmund Thum> | |> +49 7031 468-2863>
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org
Jay Turberville 17 April 2002 11:03:35 [ permanent link ]
As suggested by Irmund Thum, I ran the printenv.pl script (after installing Perl, of course). It ran fine. This lead me to a few revelations.
1) Apache 2.0 does not like a space after "<!--" when calling a CGI script. The command should be right next to the double dash. For instance: <!--#include virtual="\cgi-bin\printenv.pl" -->
2) The Win32 CGI I was trying to use are failing because they do not supply a content-type header as called for in the CGI specification. I figured this out by comparing outputs from the WinNT command line. I also figured out a simple workaround. I simply "wrapped" the Win32 executable in a batch file (.bat) like this:
@echo off echo Content-type: text/plain\n\n echo. datetime.cgi time12
"@echo off" cancels the echoing of the command line "echo" outputs the following text to standard output creating the missing content-type header. "echo." outputs a blank line - note the "." after echo. "datetime.cgi time12" is the actual execution of the command with a format argument.
3) I still do not understand why the exec cmd does not work. It seems logical that it is failing for the same lack of a header since the errors are the same. Of course, anyone having this problem could work around it by using the "exec cgi" command and wrapping the command in a .bat file similar to my example.
It seems that just about any executable could have a content-type header added to it by running it from a .bat file like this.
I would be curious to know if there is a way to force Apache to accept content without a content-type header or for Apache itself to add the content-type header.
Jay Turberville
your httpd.conf looks ok although I'd not add a + before Includes (and> not before ExecCGI).> Try to execute your cgi from> C:/Program Files/Apache Group/Apache2/cgi-bin/> and test the script printenv.pl> See also the list archive for questions around CGI with Apache2 Win> _ ___> | | Irmund Thum> | |
--------------------------------------------------------------------- The official User-To-User support forum of the Apache HTTP Server Project. See <URL:http://httpd.apache.org/userslist.html> for more info. To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org For additional commands, e-mail: users-help@httpd.apache.org