note 43834 added to function.exec
| From: | llbra at phpbrasil dot php dot net | Date: | Mon, 05 Jul 2004 21:30:30 +0000 |
| Subject: | note 43834 added to function.exec | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72630@lists.php.net to get a copy of this message | ||
If you want to run somenthing but php just keep processing data and don´t answer until the program
is closed (run in background mode, without interfering the program), from the note ( If you start a
program using this function ... PHP will hang until the execution of the program ends ), jonas
function will certainly be useful for you:
<?php
function execInBackground($path, $exe, $args = "") {
global $conf;
if (file_exists($path . $exe)) {
chdir($path);
if (substr(php_uname(), 0, 7) == "Windows"){
pclose(popen("start \"bla\" \"" . $exe . "\" " .
escapeshellarg($args), "r"));
} else {
exec("./" . $exe . " " . escapeshellarg($args) . " >
/dev/null &");
}
}
}
?>
Thank you Jonas. It has been very useful for me.
----
Manual Page -- http://www.php.net/manual/en/function.exec.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43834
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43834&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43834&report=yes
Search -- http://master.php.net/manage/user-notes.php