How to run linux bash script from web browser?

6,652

Solution 1

You want to start with Apache 'suexec':

http://httpd.apache.org/docs/2.2/suexec.html

suexec support is compiled/ready in your default Apache install on a Red Hat/CentOS/Fedora - do a Google on "suexec howto" and you'll find a lot of articles for various tools (PHP, etc.) which will give you ideas.

Solution 2

Add the following options in your apache config under your Directory (or Virtual hosts been a while so not sure on the virtual hosts bit) section.

Options ExecCGI Includes
AddHandler cgi-script .cgi

then rename your shell script to something .cgi and then make sure that the file has the correct permissions/ownership

Share:
6,652

Related videos on Youtube

warren
Author by

warren

I'm a hobbyist programmer, part-time sysadmin, and full-time analytics, big data, data center management, automation, and cloud computing architect and delivery engineer.

Updated on September 17, 2022

Comments

  • warren
    warren almost 2 years

    Hi I have web server on it also. I had made simple bash script using vi editor..which will open file and then add some lines into it at last it will save automatically...and after that 2-3 linux command will be run as a specific user.

    Now I want to do the same from web browser...so what I need to do for this? html?perl?python?cgi?....?which is easy way to do the same?

  • joews
    joews almost 10 years
    It is vitally important that, as of September 2014, you ensure that Bash is patched against Shellshock. CGI scripts are one of the main known attack vectors.