Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- shell_exec causing CGI ERROR
May 27, 2005, 1:08 am
rate this thread
I have a php page that needs to call a batch script. My test script
has one line: echo test.
I am running Win2003 Server, IIS, and php 4.3.10.
When I first tried running my php script I got an error that said
"unable to execute ...". Then I granted the IIS user execute
privledges to cmd.exe (I know, I know ... security risk).
Once I did that, my script gives me a CGI ERROR - something about http
I've scoured google groups and come up with nothing that works. I
tried one solution that uses an executable called bgrun.exe. That exe
calls my batch script - still no luck. I've tried exec() and
shell_exec(). No difference. I've tried saving the result to a
variable and not. No difference.
Any help would be greatly appreciated.
Re: shell_exec causing CGI ERROR
try system() command instead of exec(). e.g.
consider following example taken from PHP Manual
// Outputs all the result of shellcommand "ls", and returns
// the last output line into $last_line. Stores the return value
// of the shell command in $retval.
$last_line = system('ls', $retval);
// Printing additional info
<hr />Last line of the output: ' . $last_line . '
<hr />Return value: ' . $retval;