Ran into an issue in one project where I was getting an error like below:
‘/PROGRAM_NAME’ is not recognized as an internal or external command, operable program or batch file.
PROGRAM_NAME could be any Windows executable or batch file that I am trying to run through the PHP passthru(), exec() or system() functions.
This was happening on the production server where I was trying to deploy some modifications. On the staging server all the Windows command I was trying to pass through PHP was getting executed successfully. So I was pulling my hair out on what I was missing, when the staging and production machines were, more or less, identical in setup.
My first reaction was to check if the location of the executables were in the PATH environment variable. It was. So I also proceeded to run the program with its full path, but still ran into the same error. Made sure the backward slashes were being escaped properly, quotes/double quotes checked. Still the error persisted.
Searched the Internet for answers, and in majority of the pages I found with a similar issue, they always said to check if the PATH variable has the correct values.
User permissions to run the executable files was not an issue. The files I was trying to run did not require system administrator privileges.
Then, finally, I realized this could be related to either an Apache or PHP security feature. And sure it was! The PHP configuration on the production server was running with Safe Mode ON.
Yeah, _facepalm_ for not realizing this soon enough. Spent over an hour on this issue for a solution that only involved changing the value of a parameter to a few bytes.
Note: As to why I am trying to run a Windows executable through PHP? Yeah it is kind of a bad idea, but that is another story.. .
- > Notes On Nagios Configurations October 15, 2013
- > Fix ./gradlew Permission Denied On OpenShift Deploy August 15, 2020
- > When Remmina Can No Longer Connect To Remote Server October 2, 2013
- > Avoiding Errors When Setting Up Webistrano February 4, 2012
- > SuSE Linux Enterprise stock ATI Radeon driver bug? October 18, 2006