与HTML按钮运行一个shell脚本 [英] Run a shell script with an html button

查看:4487
本文介绍了与HTML按钮运行一个shell脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要当一个按钮pssed在网站上$ P $启动一个bash脚本。
这是我第一次尝试:

I want to launch a bash script when a button is pressed on a website. This is my first attempt:

<button type="button" onclick="/path/to/name.sh">Click Me!</button>

但没有运气。有什么建议?

But no luck. Any suggestions?

推荐答案

正如卢克说,你需要使用服务器端语言,如PHP。
这是一个非常简单的PHP的例子:

As stated by Luke you need to use a server side language, like php. This is a really simple php example:

<?php
if ($_GET['run']) {
  # This code will run if ?run=true is set.
  exec("/path/to/name.sh");
}
?>

<!-- This link will add ?run=true to your URL, myfilename.php?run=true -->
<a href="?run=true">Click Me!</a>

保存为 myfilename.php ,并将其放置在机器上安装使用PHP的Web服务器。同样的事情可以用ASP,JAVA,红宝石,蟒蛇来完成,...

Save this as myfilename.php and place it on a machine with a web server with php installed. The same thing can be accomplished with asp, java, ruby, python, ...

这篇关于与HTML按钮运行一个shell脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆