简体   繁体   English

使用Ajax和php执行Linux Shell命令

[英]Execute Linux shell command using ajax and php

我有一个HTML页面,并且有两个按钮,当我单击按钮时需要运行2个不同的“ sh”命令,使用PHP和Ajax如何实现呢?

You can ajax request to php page and use exec 您可以ajax请求到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>";
?>

Source: http://php.net/manual/de/function.shell-exec.php 资料来源: http : //php.net/manual/de/function.shell-exec.php

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM