There is a CentOS 7 machine and a BASH script in it.

This script is being executed either by Cron scheduler or manually when I log on to the server via SSH.

I would like to trigger script execution also by sending a POST request to a web server on the same machine (without having to log on). How to do this the right way?

1 Answer 1


There are many ways to do this. Common gateway Interface (CGI) is one. Here is a simple guide that shows you to execute a Bash script, as well as other languages, through the browser.

Some languages allow you to directly call the OS to run a program or script. For example PHP has exec().

Just a note: While executing local scripts and commands from a browser is not uncommon, there are always risks involved. Make sure you limit access to the webpage as needed, as web based access to the OS has risks.

  • 1
    Thank you. I would like only to trigger script executiion per web. No one intends that the web server should actually run the script as a child process. This script is harmless. If there is nothing to do, it does nothing.
    – Paul
    Jun 9, 2021 at 17:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.