【问题标题】:html button to call php shell_exec commandhtml 按钮调用 php shell_exec 命令
【发布时间】:2011-09-24 18:01:35
【问题描述】:

我已经谷歌了,我无法得到答案。我讨厌 php,但是外面的 php 家伙太忙了,我需要帮助!

我想从 html 按钮调用 perl 脚本。但是,我只想让它在后台运行,我不需要显示任何东西......这样的东西会起作用吗?

<html>
<body>
    <p>
        <button onclick=<?php exec('test.pl') ?>Run Perl</button>
    </p>
</body>

我不想使用 cgi,我想让它尽可能简单。

谢谢

【问题讨论】:

  • 每当有人问“这行得通”时,我的下意识反应是:“你试过了吗?”
  • 是的,它没有用......我应该改写它。我已经这样做了好几个小时了。

标签: php html shell


【解决方案1】:

这不起作用,您必须为此创建一个操作:

<?php
    if (isset($_POST['button']))
    {
         exec('test.pl');
    }
?>
<html>
<body>
    <form method="post">
    <p>
        <button name="button">Run Perl</button>
    </p>
    </form>
</body>

【讨论】:

    【解决方案2】:

    看起来您正在尝试使用 JavaScript 操作调用 PHP。这行不通。您可以尝试提交表单并在提交表单时执行PHP代码,例如:

    <?php if (isset($_POST['button'])) { exec('test.pl'); } ?>
    <form action="" method="post">
        <button type="submit" name="button">Run Perl</button>
    </form>
    

    【讨论】:

      【解决方案3】:

      解决此问题的“在后台运行”部分,您应该能够在末尾放置一个 & 以将其强制到后台。

      所以 exec('test.pl &');

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-12-06
        • 1970-01-01
        • 2016-10-07
        • 1970-01-01
        • 2013-01-23
        • 1970-01-01
        • 1970-01-01
        • 2016-07-16
        相关资源
        最近更新 更多