I'd like to create a file (e.g. script.sh) that will reside on the same server as my Magento 2 instance.
I'd like to be able to call a URL (e.g RunScript.php) that would in turn execute this script
Is this possible?
Magento Stack Exchange is a question and answer site for users of the Magento e-Commerce platform. It only takes a minute to sign up.Sign up to join this community
Use the PHP command
This takes a bash command as input which is executed. In your case it would be something like this:
<?php // RunScript.php echo shell_exec('sh script.sh'); // run script and show output ?>
Do not do this!
This approach is highly discouraged as it has all kinds of security vulnerabilities. If the
script.sh has an error or one too many
rm calls it could break your server. Requiring this solution implies a severe design flaw.