3

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.

2 Answers 2

7

Try this:

shell_exec("adb devices  2>&1")

Source: http://www.php.net/manual/en/function.shell-exec.php#106250

Sign up to request clarification or add additional context in comments.

3 Comments

That opens the shutters entirely! Now I get: dyld: Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib Expected in: /Applications/MAMP/Library/lib/libJPEG.dylib in /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/Resources/libTIFF.dylib, which suggests that either my PATH or DYLIB_PATH (whatever it's called) is wrong.
No worries, I can probably figure it out from here. It basically a DY_LIBRARY_PATH issue where the process needs to be launched correctly. The dab executable is dynamically loading libraries that the current process cannot locate. Once I figure out how to properly launch MAMP with the proper env vars I'll be all set.
Fair enough! I usually wait for a final resolution but this time I'll make an exception (without printing a stack trace)!
1

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:

#if test "x$DYLD_LIBRARY_PATH" != "x" ; then
#  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib:$DYLD_LIBRARY_PATH"
#else
#  DYLD_LIBRARY_PATH="/Applications/MAMP/Library/lib"

It works fine for me! I hope that you can enjoy it. Good Lucky!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.