Satyendra Mishra
Satyendra Mishra

Reputation: 533

Exec is not working

I am trying to automate magmi with a script

<?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";

        } 
    }

    ?>

The above code is written in my controller file. when i copy and paste the the below code in browser url it works giving me output on the browser

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

However it dosen't work if i try to use exec or shell_exec in my controller.

Upvotes: 0

Views: 578

Answers (2)

Lee
Lee

Reputation: 11

I was also seeing the same response but after few tries ended up changing the folder permissions to apache:apache the user which the service apache was running with and it worked.

Upvotes: 1

Havelock
Havelock

Reputation: 6968

According to the documentation you either have to use wget, i.e.

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

or use an appropriate cli command, i.e.

exec('magmi [cli_command']);

or maybe even better you use cURL to fetch whatever is needed over HTTP(S).

Upvotes: 0

Related Questions