【发布时间】:2018-02-21 11:17:57
【问题描述】:
我有一个 HTML 页面,它有两个按钮,当我点击按钮时,我需要运行 2 个不同的 "sh" 命令,使用 PHP 和 Ajax 我该如何实现? p>
【问题讨论】:
-
到目前为止你取得了什么成就?
-
通过写代码..
标签: javascript php ajax linux shell
我有一个 HTML 页面,它有两个按钮,当我点击按钮时,我需要运行 2 个不同的 "sh" 命令,使用 PHP 和 Ajax 我该如何实现? p>
【问题讨论】:
标签: javascript php ajax linux shell
你可以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');
?>
【讨论】:
<?php
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
?>
【讨论】: