gpt4 book ai didi

html - 使用 html 按钮运行 shell 脚本

转载 作者:技术小花猫 更新时间:2023-10-29 12:17:55 26 4
gpt4 key购买 nike

我想在网站上按下按钮时启动 bash 脚本。这是我的第一次尝试:

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

但运气不好。有什么建议吗?

最佳答案

如 Luke 所述,您需要使用服务器端语言,例如 php。这是一个非常简单的 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>

将其保存为 myfilename.php 并将其放置在装有 web 服务器并安装了 php 的机器上。同样的事情可以用 asp、java、ruby、python 来完成,...

关于html - 使用 html 按钮运行 shell 脚本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6235785/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com