note 35731 modified in function.exec by danbrown
| From: | danbrown@php.net | Date: | Sun, 04 Jan 2009 16:33:18 +0000 |
| Subject: | note 35731 modified in function.exec by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-148815@lists.php.net to get a copy of this message | ||
On WinXP with Apache2 and PHP 4.3.3 you cannot start a program in background with exec and start.
you have to do the following. This function should work on Windows and Unix, too.
<?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
&");
}
}
}
?>
I have this tested in Win XP and SUSE Linux with Apache and PHP 4.3.3.
--was--
On WinXP with Apache2 and PHP 4.3.3 you cannot start a program in background with exec and start.
you have to do the following. This function should work on Windows and Unix, too.
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
&");
}
}
}
I have this tested in Win XP and SUSE Linux with Apache and PHP 4.3.3.
http://php.net/manual/en/function.exec.php