質問

media/tmpディレクトリにzipファイルを抽出するカスタムシェルスクリプトを作成しようとしています。

シェルディレクトリにLabele.phpファイルを作成しました。Mage_Shell_Abstractを拡張し、run()は次のようになります:

/**
 * 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();
    }
}
.

から実行しているコマンドはphp -f shell/labeler.php -- unzip file.zipです。私が得る出力は次のとおりです。 unzipping 1

役に立ちましたか?

解決

私が知っていることから私は正しい構文が次のものであると思います:

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

マゼントのシェルスクリプトの構文は次のとおりです。

php -f script.php -- [options]
.

ここでのオプションは、このような単なるフラグかもしれません:

php -f script.php -- test
. その場合、$this->getArg('test')は1を返します(true)

またはそれはこのような値かもしれません:

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

その場合、$this->getArg('test')は 'MyTest'

を返します。

ライセンス: CC-BY-SA帰属
所属していません magento.stackexchange
scroll top