views:

112

answers:

2

Hi,

I'm running Apache 2.2 (launched via console) on Vista. I have simple batch script in cgi-bin. Unfortunately, Apache does not seem to serve any content generated by sub-processes.

For example, given the following script:

@echo off
echo Content-Type: text/html
echo.
echo Visible in browser
cmd /c echo Hidden from browser
echo End of script

All three lines of text will appear in the console if executed directly from a command prompt. However the middle line ("Hidden from browser") will not appear if the script is launched from Apache.

This script is just illustrative -- I'm actually using the batch file to launch a number of separate console based applications (not cmd.exe)

What am I doing wrong?

A: 

It would work from the command line as expected but what are the applications that you are trying to run in apache's cgi-bin? I have not heard of Apache's cgi-bin being a batch file...and that could be a potential exploit...maybe the permissions are not set for the batch file...or that there is no plugin available for Apache to actually execute a batch file, think of the mod handlers used for ssl (secure sockets layer)...like this as an example found in Apache's config file...httpd.conf

<LoadModule ssl_module modules/mod_ssl.so>
....
<if mod_ssl>
....
</if>

This would explain why you cannot run a batch file as a cgi-bin script...

Hope this helps, Best regards, Tom.

tommieb75
A: 

Maybe you need to redirect the output to your STDOUT. I haven't tried it on Windows machine, but you could try

cmd /c echo Hidden from browser >&1

or redirect it to a temp file and call type on the file.

eed3si9n
`echo` outputs on `stdout` already ...
Joey
@Johannes Rössel echo in your own process does, but what about the one that run in subprocess?
eed3si9n