通过URL在远程服务器中执行bash脚本

时间:2016-02-08 18:22:50

标签: bash execution

我的远程服务器“A”下面有一个bash脚本“Hello.sh”,它正在运行Apache。

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

我想在远程服务器“A”中执行此脚本,方法是从服务器“B”调用它的Apache URL,如下所示。

请注意我已通过URL将脚本保存在Apache的Document根目录中。

http://Server_A:PORT/Hello.sh

如何实现这一目标。感谢。

1 个答案:

答案 0 :(得分:0)

为了能够直接从浏览器运行shell脚本,您应该将此规则添加到.htaccess文件中。

选项ExecCGI AddHandler cgi-script .sh

这告诉Web服务器将.sh文件视为CGI脚本。

相关问题