我正在尝试使用脚本
自动化magmi<?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";
}
}
?>
上面的代码写在我的控制器文件中。 当我在浏览器网址中复制并粘贴以下代码时,它可以在浏览器上输出
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 :(得分:1)
我也看到了相同的响应,但经过几次尝试最终将文件夹权限更改为apache:apache运行服务apache的用户并且它有效。
答案 1 :(得分: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)所需的任何内容。