Unable to run executables, only shell commands
--------------------------------------------------------------------------------
Hello.
I am running php 5.1.1 and IIS Windows XP SP2. I have figured out how to get exec() and passthru() to work by enabling read and execute permissions for iwam and iusr accounts on cmd.exe as well as the executable I am trying to run.
I can get things like exec("dir"); to work and exec("date /t");, but these are system shell commands, not executables.
When I try to run an executable by this means:
exec("x:\\path\\chkdsk.exe c:",$output,$returnval);
I get no $output but the $returnval is 1.
I'm at a loss...I'm not sure why this won't work. shell_exec() won't work at all even with shell commands, and passthru() behaves similarly to exec();
Any suggestions?hi sunshadow_x,
I am running into the same problem as yours. Did you figure out what's the problem. On php.net I found that increasing memory_limit in php.ini might help. But that din't really solved my problem. Please let me know if you got a solution. This is urgent for me.
Regards,
RiteshHave you tried:
1. Doing the same thing from PHP CLI?
2. Doing the same thing from CMD.EXE when logged on as the user which PHP runs under?
3. Writing a CGI script to try to do the same?
If the answer is "all three", I'm stumped.
It could be to do with user permissions.
If you're running IIS, it's probably because IIS does not load the profile of the user properly- I know of no fix. A lot of things cannot be run from CGI under IIS because of this and there's no work-around.
MarkHi Mark,
Thanks for your reply...but the answer lies in the full path of perl.exe. Although when running the command from command prompt, my system was able to identify the location of perl.exe but when I tried to run using shell_exec it was unable to identify the location of perl.exe. But giving the full path of perl.exe (i.e. c:\perl\bin\perl.exe) in shell_exec solved the problem
Regards,
Ritesh
--------------------------------------------------------------------------------
Hello.
I am running php 5.1.1 and IIS Windows XP SP2. I have figured out how to get exec() and passthru() to work by enabling read and execute permissions for iwam and iusr accounts on cmd.exe as well as the executable I am trying to run.
I can get things like exec("dir"); to work and exec("date /t");, but these are system shell commands, not executables.
When I try to run an executable by this means:
exec("x:\\path\\chkdsk.exe c:",$output,$returnval);
I get no $output but the $returnval is 1.
I'm at a loss...I'm not sure why this won't work. shell_exec() won't work at all even with shell commands, and passthru() behaves similarly to exec();
Any suggestions?hi sunshadow_x,
I am running into the same problem as yours. Did you figure out what's the problem. On php.net I found that increasing memory_limit in php.ini might help. But that din't really solved my problem. Please let me know if you got a solution. This is urgent for me.
Regards,
RiteshHave you tried:
1. Doing the same thing from PHP CLI?
2. Doing the same thing from CMD.EXE when logged on as the user which PHP runs under?
3. Writing a CGI script to try to do the same?
If the answer is "all three", I'm stumped.
It could be to do with user permissions.
If you're running IIS, it's probably because IIS does not load the profile of the user properly- I know of no fix. A lot of things cannot be run from CGI under IIS because of this and there's no work-around.
MarkHi Mark,
Thanks for your reply...but the answer lies in the full path of perl.exe. Although when running the command from command prompt, my system was able to identify the location of perl.exe but when I tried to run using shell_exec it was unable to identify the location of perl.exe. But giving the full path of perl.exe (i.e. c:\perl\bin\perl.exe) in shell_exec solved the problem
Regards,
Ritesh