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?
I think your guess is correct. The exe file probably writes to the screen rather than
stdout
.Forgive me for saying this if I'm wrong, but does Apache know how to execute a CMD file? In essence, I would expect you would have to give the script to apache in a manner it can understand. Perhaps you'd have more luck attempting to have a perl script execute the CMD and stream the output that way instead of attempting to directly execute the CMD script.