How to run shell scripts from a browser?
To run shell scripts directly from the browser, add this rule to your .htaccess file:
Options +ExecCGI
AddHandler cgi-script .sh
This tells the web server to treat .sh files as CGI scripts.
To test this, let’s try printing today’s date in your browser. To do this, create a file called date.sh with the following content:
#!/bin/bash
DATE="$(date)"
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Test</title></head><body>"
echo "Today is $DATE <br>"
Save the file and change its permissions to 755.
Now open www.yourdomain.com/date.sh and the output you get should be similar to this:
Today is Sun Jan 21 09:01:38 CST 2018