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
-
2Whenever someone asks "Will this work", my knee-jerk reaction is: "Have you tried?"troelskn– troelskn2011年09月24日 18:05:27 +00:00Commented Sep 24, 2011 at 18:05
-
Yes and it didn't work... I should have rephrased it. I have been doing this for hours.JonnyCplusplus– JonnyCplusplus2011年09月24日 18:10:07 +00:00Commented Sep 24, 2011 at 18:10
3 Answers 3
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>
Comments
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
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 &');