Question

I'm attempting to create a custom shell script that will extract a zip file in my media/tmp directory.

I've created a labeler.php file in the shell directory. It extends Mage_Shell_Abstract and run() looks like this:

/**
 * Run script
 *
 */
public function run()
{
    $_SESSION = array();
    if ($this->getArg('unzip')) {
        $zipFile = strval($this->getArg('unzip'));
        echo "Unzipping {$zipFile}";
    }elseif ($this->getArg('pendingList')) {
        echo "this\n";
    } else {
        echo $this->usageHelp();
    }
}

The command that I am executing from is php -f shell/labeler.php -- unzip file.zip. The output that I get is: Unzipping 1

Was it helpful?

Solution

From what I know I think the right syntax is the following:

php -f shell/labeler.php -- --unzip file.zip

The syntax for shell script in Magento is :

php -f script.php -- [options]

Where options could be just a flag like this:

php -f script.php -- test

In that case $this->getArg('test') will return 1 (true).

Or it could be a value like this:

php -f script.php -- --test mytest

In that case $this->getArg('test') will return 'mytest'

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top