2013-04-23 90 views
0

我想用一個腳本Exec的工作不

<?php 
class Trainingsatyendra_Feedback_IndexController extends Mage_Core_Controller_Front_Action 
{ 
     public function indexAction() 
     { 

    exec('localhost/practice/magmi/web/magmi_run.php?mode=create&pr 
    ofile=default&engine=magmi_productimportengine:Magmi_ProductImportEngine&CSV:f 
    ilename=catalog_product_20130422_073721.csv',$result); 
     var_dump($result); 
     if($result) 
     { 
     echo "shell successfully executed"; 
     } 
     else 
     echo "shell Not executed"; 

     } 
    } 

    ?> 

上面的代碼寫在我的控制文件自動magmi。 當我複製並粘貼下面的代碼在瀏覽器的URL它可以讓我在瀏覽器上

localhost/practice/magmi/web/magmi_run.php?mode=create&pr 
ofile=default&engine=magmi_productimportengine:Magmi_ProductImportEngine&CSV:f 
ilename=catalog_product_20130422_073721.csv 

輸出然而,如果我嘗試使用EXEC或在了shell_exec我的控制器是這麼想的工作。

+0

添加http:// localhost之前? – 2013-04-23 06:52:12

+0

您不需要Web服務器上的'exec'腳本。您可以在文件系統中使用可執行文件。您可以在命令行中運行的任何程序都應該可以使用'exec'運行。 – Havelock 2013-04-23 06:54:50

+0

@chandresh_cool你的意思是像'wget http:// localhost ...'這樣的東西嗎? – Havelock 2013-04-23 06:55:25

回答

0

按照documentation你要麼必須使用wget,即

exec('wget http://localhost/practice/magmi/web/magmi_run.php?mode=create&profile=default&engine=magmi_productimportengine:Magmi_ProductImportEngine&CSV:filename=catalog_product_20130422_073721.csv'); 

或使用適當的cli command,即

exec('magmi [cli_command']); 

,或者甚至更好的使用cURL獲取任何需要在HTTP(S)。

+0

不,上面的soln不工作不是wget也不是cURL工作 – 2013-04-23 07:15:02

+0

請定義'not working'。 – Havelock 2013-04-23 07:20:00

1

我也看到相同的響應,但經過幾次嘗試後,文件夾權限更改爲apache:apache服務apache運行的用戶,它的工作。