You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Paul Sutton <pa...@awe.com> on 1999/01/30 21:02:30 UTC

[Win32] CGI batch file problem?

Erm, something seems to be up with CGI execution of batch files, unless
I'm doing something strange.

Here is what I did:

 - Create a file called 1.bat, containing just the line

echo HelloDown

 - Put that into a script-aliased directory
 - Request it:

-----

% telnet winnt 8080
GET /cgi-bin/1.bat HTTP/1.0

HTTP/1.1 200 OK
Date: Sat, 30 Jan 1999 19:54:15 GMT
Server: Apache/1.3.5-dev (Win32)
Connection: close
Content-Type: text/plain

d:\apache\cgi-bin>echo HelloDown 
HelloDown
Connection closed by foreign host.

------

Look, it showed me the full path of the file directory (!), what it was
executing and the results. So the output is consistent with a batch file
that doesn't start @echo off, but where Apache doesn't parse the scriput
output. Adding @echo off makes things work as expected (i.e. in this case,
get a 500 server error because of premature end of headers).

I would look into this more, but it is the end of the day and if this is
reproducable it looks like a serious problem so I though I'd mail it now.

Paul

PS the test comes from PR#3574, with a different result (submitter says it
"kills" Apache 1.3.2). I didn't expect it to, but I did expect it to give
a 500 server error.


Re: [Win32] CGI batch file problem?

Posted by Paul Sutton <pa...@awe.com>.
On Sat, 30 Jan 1999, Marc Slemko wrote:
> On Sat, 30 Jan 1999, Paul Sutton wrote:
> > Erm, something seems to be up with CGI execution of batch files, unless
> > I'm doing something strange.
> 
> Why do you think the behaviour you are seeing is odd?
> 
> What you are probably getting from the .bat file is a blank line, then
> the output you see to the client.  A blank line terminates the CGI 
> headers, which happen to be empty.  The rest is what you should get.

Yeah, you are right, the blank line at the start of output is actually
part of the script output. I assumed it was part of the interactive shell.
So "echo" mode in a batch file doesn't just echo the commands, it also
echo a blank line before echoing each command to be executed.

Paul





RE: [Win32] CGI batch file problem?

Posted by Allan Edwards <ak...@raleigh.ibm.com>.
try this:

@echo off
echo Content-type: text/html
echo.
echo SERVER_SOFTWARE = %SERVER_SOFTWARE%

Allan
> -----Original Message-----
> From: new-httpd-owner@apache.org [mailto:new-httpd-owner@apache.org]On
> Behalf Of Marc Slemko
> Sent: Saturday, January 30, 1999 3:55 PM
> To: Apache
> Subject: Re: [Win32] CGI batch file problem?
> 
> 
> On Sat, 30 Jan 1999, Paul Sutton wrote:
> 
> > Erm, something seems to be up with CGI execution of batch files, unless
> > I'm doing something strange.
> 
> Why do you think the behaviour you are seeing is odd?
> 
> What you are probably getting from the .bat file is a blank line, then
> the output you see to the client.  A blank line terminates the CGI 
> headers, which happen to be empty.  The rest is what you should get.
> 

Re: [Win32] CGI batch file problem?

Posted by Marc Slemko <ma...@worldgate.com>.
On Sat, 30 Jan 1999, Paul Sutton wrote:

> Erm, something seems to be up with CGI execution of batch files, unless
> I'm doing something strange.

Why do you think the behaviour you are seeing is odd?

What you are probably getting from the .bat file is a blank line, then
the output you see to the client.  A blank line terminates the CGI 
headers, which happen to be empty.  The rest is what you should get.