我一直在使用以下PHP脚本在服务器上触发bash脚本:
<?php
$output = shell_exec('cat update.sh | ssh -l some_user -i key foo.bar.com');
echo "<pre>$output</pre>";
?>
由于我无法控制的问题,我们更换了服务器,我无法运行 PHP(不要问)。我可以在这里使用另一种语言来完成此任务吗?显然,我可以用HTTP POST定位的东西。谢谢。
你可以使用老式的cgi-bin,直接运行bash脚本:
#!/bin/bash
x=`cat update.sh | ssh -l some_user -i key foo.bar.com`
echo <<EOL
Content-type: text/html
<pre>$x</pre>
EOL
你可以直接使用 cgi 运行 bash 脚本。
#!/bin/bash
OUTPUT=`cat update.sh | ssh -l some_user -i key foo.bar.com`
# You must add following two lines before
# outputting data to the web browser from shell
# script
echo "Content-type: text/html"
echo ""
echo "<html><head><title>Demo</title></head><body>"
echo "$OUTPUT <br>"
echo "</body></html>"
这里的一些代码
这取决于服务器配置。任务非常简单,因此您可以在提供商提供的每种(我猜)技术中完成;)
如果你有权访问 perl:
#!/usr/bin/env perl
++$|;
print '<pre>';
system ('your command 2>&1');
print '</pre>';
Python和许多其他人是相似的。