簡體   English   中英

php exec()返回空值

[英]php exec() returning empty value

目前,我的目標是使用see PHP exec()的輸出,但得到一個空值。 我正在使用firephp(firebug擴展)日志記錄,無法弄清為什么它為空。

完整代碼在這里: https : //github.com/MattMcFarland/ninja-forms-uploads-custom/blob/dev/uploads-custom.php

此處的表格: 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);

當前控制台顯示我正在使用的每個exec方法為空。 真的不知道該怎么辦,真是無所適從。

控制台也可以正常工作,因為它顯示了其他fb(); 東西。 exec命令顯示的空行前面帶有數字3,表示空返回3次。

有任何想法嗎?

如果exec找不到您要運行的命令,它將為空。 您需要告訴php使用putenv可以在哪里找到它。 在我的情況下,mogrify的路徑是/ opt / local / bin。 因此,以下代碼將起作用,您只需要為您的環境使用正確的路徑即可。

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);

希望對您有所幫助。

問題是權限問題。 不允許用戶使用BASH。

必須將apache用戶的/ etc / passwd中的bin / false更改為bin / bash。

事后看來,僅添加bin / mogrify可能會更好

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM