How to run a cmd.exe cmd file as an apache for windows cgi

cgiwindows-command-prompt

It sounds simple enough, but I'm having a hell of a time getting it to work.
Apache expects the first line of my script to say #!<path_to_cmd_shell>
And I don't want to use perl or anything else, I want to use c:\windows\system32\cmd.exe
But no go.

When I run the rest of the cmd file from the cmd prompt, it works as expected.

I even have a test cgi that does this:

@echo off
echo Content-Type: text/html
echo.
echo ^<html^>^<head^>^</head^>^<body^>hi from stu the cgi ^</body^>^</html^>

and that works.

But when I change the script to run another exe (whose output would be the cgi response) I get all sorts of premature end of script headers.

I'm guessing that it has something to do with the output of the exe not piping back through the shell's output.

Any idea how to make this go?

Best Answer

I think your guess is correct. The exe file probably writes to the screen rather than stdout.