3

I have google the heck out of this an I cannot get an answer to this. I hate php, but out php guy is too busy and I need HELP!

I want to call a perl script from an html button. But, I just want it to run in the back ground, I don't need to display anything from it... Would something like this work?

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

I would prefer not to use cgi, I want to keep this as simple as possible.

Thanks

2
  • 2
    Whenever someone asks "Will this work", my knee-jerk reaction is: "Have you tried?" Commented Sep 24, 2011 at 18:05
  • Yes and it didn't work... I should have rephrased it. I have been doing this for hours. Commented Sep 24, 2011 at 18:10

3 Answers 3

5

That will not works, you have to create an action for that:

<?php
    if (isset($_POST['button']))
    {
         exec('test.pl');
    }
?>
<html>
<body>
    <form method="post">
    <p>
        <button name="button">Run Perl</button>
    </p>
    </form>
</body>
Sign up to request clarification or add additional context in comments.

Comments

3

Looks like you are trying to call PHP with a JavaScript action. This will not work. You can try submitting a form and executing the PHP code when the form is submitted, like:

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

Comments

0

Addressing the 'run in background' part of this problem, you should be able to put an & at the end to force it to the background.

So exec('test.pl &');

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.