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

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







          Popular posts from this blog

          Magento 2 duplicate PHPSESSID cookie when using session_start() in custom php scriptMagento 2: User cant logged in into to account page, no error showing!Magento duplicate on subdomainGrabbing storeview from cookie (after using language selector)How do I run php custom script on magento2Magento 2: Include PHP script in headerSession lock after using Cm_RedisSessionscript php to update stockMagento set cookie popupMagento 2 session id cookie - where to find it?How to import Configurable product from csv with custom attributes using php scriptMagento 2 run custom PHP script

          Can not update quote_id field of “quote_item” table magento 2Magento 2.1 - We can't remove the item. (Shopping Cart doesnt allow us to remove items before becomes empty)Add value for custom quote item attribute using REST apiREST API endpoint v1/carts/cartId/items always returns error messageCorrect way to save entries to databaseHow to remove all associated quote objects of a customer completelyMagento 2 - Save value from custom input field to quote_itemGet quote_item data using quote id and product id filter in Magento 2How to set additional data to quote_item table from controller in Magento 2?What is the purpose of additional_data column in quote_item table in magento2Set Custom Price to Quote item magento2 from controller

          How to solve knockout JS error in Magento 2 Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?(Magento2) knockout.js:3012 Uncaught ReferenceError: Unable to process bindingUnable to process binding Knockout.js magento 2Cannot read property `scopeLabel` of undefined on Product Detail PageCan't get Customer Data on frontend in Magento 2Magento2 Order Summary - unable to process bindingKO templates are not loading in Magento 2.1 applicationgetting knockout js error magento 2Product grid not load -— Unable to process binding Knockout.js magento 2Product form not loaded in magento2Uncaught ReferenceError: Unable to process binding “if: function()return (isShowLegend()) ” magento 2