ultrus Posted July 2, 2009 Share Posted July 2, 2009 Hi, The following works fine: <?php $command = 'ls'; exec($command, $output); print_r($output); //all files and folders are listed in my current php file directory ?> However, when I try to run a 3rd party program of any kind from command line, nothing happens. No errors. No results either. I can echo out the command I'm running, copy, paste into terminal, and it runs fine. I'm thinking it's some kind of user permission issue? Any guess on how to resolve this? I'm using MAMP. Thanks much. Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/ Share on other sites More sharing options...
rhodesa Posted July 2, 2009 Share Posted July 2, 2009 What is the command you are running? Make sure you are using the FULL path to the file. Also, try running it like this: /full/path/to/file 2>&1 that will send any output that is going to STDERR to STDOUT Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/#findComment-867871 Share on other sites More sharing options...
ultrus Posted July 2, 2009 Author Share Posted July 2, 2009 Hello rhodesa, Thanks for the quick feedback. Your tip returned an error message array. command: swift "test" 2>&1 output: Array ( [0] => dyld: Symbol not found: __cg_jpeg_resync_to_restart [1] => Referenced from: /System/Library/Frameworks/ApplicationServices.framework/Versions/A/Frameworks/ImageIO.framework/Versions/A/ImageIO [2] => Expected in: /Applications/MAMP/Library/lib/libJPEG.dylib [3] => ) What's supposed to happen is the computer will say "hello" using Cepstral's text-to-speech engine and command line program they call Swift. Not sure what this has to do with jpegs. Any thoughts?: I'll start digging around. Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/#findComment-867902 Share on other sites More sharing options...
rhodesa Posted July 2, 2009 Share Posted July 2, 2009 Can you post the actual PHP code you are executing? Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/#findComment-867906 Share on other sites More sharing options...
ultrus Posted July 2, 2009 Author Share Posted July 2, 2009 Sure thing. Here it is in full: <?php class Swift { public $defaultVoice; //not used yet public function __construct() { //stuff soon } public function sayHello() { $output = ""; $command = 'swift "test" 2>&1'; exec($command, $output); print_r($output); return true; } } //example usage: $swift = new Swift(); $swift->sayHello(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/#findComment-867916 Share on other sites More sharing options...
ultrus Posted July 2, 2009 Author Share Posted July 2, 2009 Ah got it! It's a MAMP bug. The solution is this: export DYLD_LIBRARY_PATH=""; swift "test" Thanks again for your help. Quote Link to comment https://forums.phpfreaks.com/topic/164539-solved-exec-issue-on-my-mac/#findComment-867949 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.