javascript - 使用 ajax 和 php 执行 Linux shell 命令

标签 javascript php ajax linux shell

我有一个 HTML 页面,它有两个按钮,我需要在单击按钮时运行 2 个不同的 "sh" 命令,使用 PHP 和 Ajax 我该如何实现?

最佳答案

您可以 ajax request到 php 页面并使用 exec

<?php
    // outputs the username that owns the running php/httpd process
    // (on a system with the "whoami" executable in the path)
    echo exec('whoami');
?>

关于javascript - 使用 ajax 和 php 执行 Linux shell 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48904517/

相关文章:

javascript - 使用 javascript 滚动时如何保持类事件?

javascript - 数组的 typescript 编译错误

javascript - 如何将呈现的 HTML 传递给 vue 属性?

php - MySQL:如果小于 now() 加 1 个月,则选择日期加 6 个月

php 登录不显示 true 或 false

javascript - RobinBrouwer WMD - 阅读基本 jQuery

复选框 html 表单的 php 代码

javascript - Jquery $.ajax() 调用将关联数组与其他参数传递给 MVC Controller 失败

jQuery ajax 工具提示 : where to find a nice plugin?

jquery - Jquery Ajax 请求响应错误