Sharath Arakere February 2016

Execute a bash script in remote server through URL

I have a bash script "Hello.sh" below in my remote server "A" which is running Apache.

#! /bin/bash
echo "Hello World" > Hello.txt

I want to execute this script in remote server "A" itself by calling it's Apache URL from server "B" like below.

Please note I have made the script available through URL by keeping it in Document root of Apache.

http://Server_A:PORT/Hello.sh

How can this be accomplished. Thanks.

Answers


JazzCat February 2016

To be able to run shell scripts directly from the browser, you should add this rule to your .htaccess file.

Options ExecCGI AddHandler cgi-script .sh

This tells the webserver to treat .sh files as CGI scripts.

Post Status

Asked in February 2016
Viewed 3,565 times
Voted 8
Answered 1 times

Search




Leave an answer