如何从HTML页面运行shell脚本? [英] How to run a shell script from an HTML page?

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

问题描述

我想在html页面 input.html 上创建一个按钮和一个输入框,点击时应该执行一个shell脚本 test .SH 。 shell脚本应该将该输入框字符串作为参数。 shell脚本创建一个html文件 out.html (我已经创建了shell脚本,它在输入字符串时生成一个html文件),然后我想显示在原始HTML页面 input.html



我该怎么做?假设一切都在本地运行,即没有服务器的东西。

 <?php 
if($ _GET ['run']){
#This如果设置了?run = true,代码将运行。
exec(/ path / to / name.sh);
}
?>

<! - 这个链接将会添加?run = true到你的URL,myfilename.php?run = true - >
< a href =?run = true>点击我!< / a>


I want to make a single button and an input box on an html page input.html, which when clicked should execute a shell script test.sh. The shell script should take that input box string as parameter. The shell script creates an html file out.html (I have created the shell script, which when takes an input string, produces an html file), which then I want to show on original html page input.html.

How can I do this ? Assume everything is running locally i.e. no server thing here.

解决方案

You might want to try loading that from server side language (like PHP)

<?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>

这篇关于如何从HTML页面运行shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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