1

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?

2 Answers 2

1

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

0

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.

1
  • The first thing I tried was the @echo off in the first line, that seemed to tip apache off to something, because when I take that out, it just dumps the file contents to the browser. The other thing I tried was to put #!c:\windows\system32\cmd.exe as the first line so it would use that as the shell, and it did run that, but the stdout part doesn't work.
    – Stu
    Sep 4, 2009 at 17:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .