I am a complete PHP (LAMP/WAMP/MAMP) noob and I'm running into what seems to be a common issue among noobs trying to run shell commands from a web server. I have a MAMP setup on a Mac mini and I want to collect the output from an Android command,
adb devices
so I can display a list of devices attached to my mac mini. whenever I pass the command to shell_exec in my PHP script I get an empty string returned. I cannot figure out how to resolve the issue after several web searches. I tried running
shell_exec("who am i")
which returns "Clifton", the name of the user account that launched MAMP. I verified that this same user account can execute the "adb devices" command. The Android tools are installed in that user account's home folder. I've also tried passing the absolute path to the command. At this point, I am certain that is a configuration issue but I don't know what to configure or where.
Try this:
Source: http://www.php.net/manual/en/function.shell-exec.php#106250
You should try to open the file /Applications/MAMP/Library/bin/envvars and then comment the four lines of if and else. This is looks like this:
It works fine for me! I hope that you can enjoy it. Good Lucky!