How to run external script outside of magento 2 root directory? Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Magento 1.9.2.1 Cron Not WorkingMagento 2 admin url gives error - Class MagentoAuthorizationModelRoleFactory does not existmagento 2 setup freezes browserCron Permissions Error Magento2Running Cron Scripts From a Sub-directoryReadiness check didn't have a problem, but update.log complains about non-writable pathsMagento 2 Cron PHP Parse ErrorHelp with Cron on Magento 2Run custom PHP file via Cron jobMagento 2 - Make log file accessible from browser

Multi tool use
Multi tool use

How do I make this wiring inside cabinet safer?

Should I use a zero-interest credit card for a large one-time purchase?

Is CEO the "profession" with the most psychopaths?

How do living politicians protect their readily obtainable signatures from misuse?

How to compare two different files line by line in unix?

What was the first language to use conditional keywords?

Central Vacuuming: Is it worth it, and how does it compare to normal vacuuming?

Chebyshev inequality in terms of RMS

How would a mousetrap for use in space work?

Is grep documentation about ignoring case wrong, since it doesn't ignore case in filenames?

Is there any word for a place full of confusion?

Localisation of Category

Do I really need to have a message in a novel to appeal to readers?

Can an alien society believe that their star system is the universe?

How could we fake a moon landing now?

How can I reduce the gap between left and right of cdot with a macro?

Is it fair for a professor to grade us on the possession of past papers?

A term for a woman complaining about things/begging in a cute/childish way

When a candle burns, why does the top of wick glow if bottom of flame is hottest?

Chinese Seal on silk painting - what does it mean?

Did Krishna say in Bhagavad Gita "I am in every living being"

Most bit efficient text communication method?

How does light 'choose' between wave and particle behaviour?

What do you call the main part of a joke?



How to run external script outside of magento 2 root directory?



Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 1.9.2.1 Cron Not WorkingMagento 2 admin url gives error - Class MagentoAuthorizationModelRoleFactory does not existmagento 2 setup freezes browserCron Permissions Error Magento2Running Cron Scripts From a Sub-directoryReadiness check didn't have a problem, but update.log complains about non-writable pathsMagento 2 Cron PHP Parse ErrorHelp with Cron on Magento 2Run custom PHP file via Cron jobMagento 2 - Make log file accessible from browser



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.



I tried to move the script to




magentoroot/script/




, and change the following in the script:




$file = fopen('../../qty.csv', 'r', '"');



require DIR . '../app/bootstrap.php';



$writer = new ZendLogWriterStream(BP .
'../var/log/import-update.log');




then the script stop working. what should i change in the file?



<?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
if ($file !== false) {

require __DIR__ . '/app/bootstrap.php';
$bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();


$state = $objectManager->get('MagentoFrameworkAppState');
$state->setAreaCode('adminhtml');

// used for updating product info
$productRepository = $objectManager->get('MagentoCatalogModelProductRepository');

// used for updating product stock
$stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');

// add logging capability
$writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
$logger = new ZendLogLogger();
$logger->addWriter($writer);
.....
.....
.....









share|improve this question






























    0















    I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.



    I tried to move the script to




    magentoroot/script/




    , and change the following in the script:




    $file = fopen('../../qty.csv', 'r', '"');



    require DIR . '../app/bootstrap.php';



    $writer = new ZendLogWriterStream(BP .
    '../var/log/import-update.log');




    then the script stop working. what should i change in the file?



    <?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
    if ($file !== false) {

    require __DIR__ . '/app/bootstrap.php';
    $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
    $objectManager = $bootstrap->getObjectManager();


    $state = $objectManager->get('MagentoFrameworkAppState');
    $state->setAreaCode('adminhtml');

    // used for updating product info
    $productRepository = $objectManager->get('MagentoCatalogModelProductRepository');

    // used for updating product stock
    $stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');

    // add logging capability
    $writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
    $logger = new ZendLogLogger();
    $logger->addWriter($writer);
    .....
    .....
    .....









    share|improve this question


























      0












      0








      0








      I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.



      I tried to move the script to




      magentoroot/script/




      , and change the following in the script:




      $file = fopen('../../qty.csv', 'r', '"');



      require DIR . '../app/bootstrap.php';



      $writer = new ZendLogWriterStream(BP .
      '../var/log/import-update.log');




      then the script stop working. what should i change in the file?



      <?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
      if ($file !== false) {

      require __DIR__ . '/app/bootstrap.php';
      $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
      $objectManager = $bootstrap->getObjectManager();


      $state = $objectManager->get('MagentoFrameworkAppState');
      $state->setAreaCode('adminhtml');

      // used for updating product info
      $productRepository = $objectManager->get('MagentoCatalogModelProductRepository');

      // used for updating product stock
      $stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');

      // add logging capability
      $writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
      $logger = new ZendLogLogger();
      $logger->addWriter($writer);
      .....
      .....
      .....









      share|improve this question
















      I have made a few external php scripts to update quantity and tracking numbers,etc Right now, i'm putting them in magento root and set the permission to 640. However, it's still accessible by the browser. I would like to make it accessible by cron and the owner/group only.



      I tried to move the script to




      magentoroot/script/




      , and change the following in the script:




      $file = fopen('../../qty.csv', 'r', '"');



      require DIR . '../app/bootstrap.php';



      $writer = new ZendLogWriterStream(BP .
      '../var/log/import-update.log');




      then the script stop working. what should i change in the file?



      <?php $file = fopen('../qty.csv', 'r', '"'); // set path to the CSV file
      if ($file !== false) {

      require __DIR__ . '/app/bootstrap.php';
      $bootstrap = MagentoFrameworkAppBootstrap::create(BP, $_SERVER);
      $objectManager = $bootstrap->getObjectManager();


      $state = $objectManager->get('MagentoFrameworkAppState');
      $state->setAreaCode('adminhtml');

      // used for updating product info
      $productRepository = $objectManager->get('MagentoCatalogModelProductRepository');

      // used for updating product stock
      $stockRegistry = $objectManager->get('MagentoCatalogInventoryApiStockRegistryInterface');

      // add logging capability
      $writer = new ZendLogWriterStream(BP . '/var/log/import-update.log');
      $logger = new ZendLogLogger();
      $logger->addWriter($writer);
      .....
      .....
      .....






      magento2 cron permissions script file-permissions






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 3 mins ago







      Kris Wen

















      asked 2 hours ago









      Kris WenKris Wen

      1589




      1589




















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "479"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270717%2fhow-to-run-external-script-outside-of-magento-2-root-directory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Magento Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f270717%2fhow-to-run-external-script-outside-of-magento-2-root-directory%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          K9i6ZW4dp5,ntCDBD t7HPJvwY13bkb6betxYvgj6yy3a iCmIC4DVSsml,SHOXi6yQ9vea WN,k3oYxMsWeMY 3umksbH,X8g
          DyU kJrLoONZbS3sXave HMH,c3Sh01W,hQk 3D,5xUD06,9u2tXbjkEX8,iOwtX2Kd80tDFDsIb1sdTrtA8,lq1cWGZAHoc2b,n OQ,qAxR,i

          Popular posts from this blog

          Nissan Patrol Зміст Перше покоління — 4W60 (1951-1960) | Друге покоління — 60 series (1960-1980) | Третє покоління (1980–2002) | Четверте покоління — Y60 (1987–1998) | П'яте покоління — Y61 (1997–2013) | Шосте покоління — Y62 (2010- ) | Посилання | Зноски | Навігаційне менюОфіційний український сайтТест-драйв Nissan Patrol 2010 7-го поколінняNissan PatrolКак мы тестировали Nissan Patrol 2016рвиправивши або дописавши її

          Best approach to update all entries in a list that is paginated?Best way to add items to a paginated listChoose Your Country: Best Usability approachUpdate list when a user is viewing the list without annoying themWhen would the best day to update your webpage be?What should happen when I add a Row to a paginated, sorted listShould I adopt infinite scrolling or classical pagination?How to show user that page objects automatically updateWhat is the best location to locate the comments section in a list pageBest way to combine filtering and selecting items in a listWhen one of two inputs must be updated to satisfy a consistency criteria, which should you update (if at all)?

          Буцька Катерина Петрівна Зміст Біографія | Фільмографія | Дублювання та озвучення українською | Дублювання та озвучення російською | Озвучення реклами | Навігаційне менюперевірена109 змінвиправивши або дописавши її