質問

Currently my goal is to use see the output of PHP exec() but getting an empty value. Am using firephp (firebug extension) logging and can't figure out why it is empty.

full code here: https://github.com/MattMcFarland/ninja-forms-uploads-custom/blob/dev/uploads-custom.php

Form here: http://www.hvac-hacks.com/?page_id=1383&preview=true&form_id=96

            exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name,$ouput);
            fb($output);
            curl_exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name,$output);
            fb($output);
            $output = shell_exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name);
            fb($output);

Currently console shows empty for each exec method I'm using. Really not sure what to do, am at a complete loss.

The console IS working as well, as it shows other fb(); stuff. The exec commands are showing an empty line with the number 3 in front of it, indicating empty return 3 times.

Any ideas?

役に立ちましたか?

解決

Problem was a permissions issue. the user was not allowed to use BASH.

Had to change bin/false to bin/bash in /etc/passwd for apache user.

In hindsight might be better to just add bin/mogrify

他のヒント

exec will be empty if it can not find the command you are trying to run. You need to tell php where it can find mogrify by using putenv. In my case mogrify's path is /opt/local/bin. So the following code would work, you will just need to use the correct path for your environment.

putenv("PATH=/opt/local/bin");
exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name,$ouput);
fb($output);
curl_exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name,$output);
fb($output);
$output = shell_exec('mogrify -auto-orient -verbose -format jpg '.$dir."/".$user_file_name);
fb($output);

I hope that helps.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top