note 18331 added to ref.exec

From: Date: Fri, 18 Jan 2002 17:04:15 +0000
Subject: note 18331 added to ref.exec
Groups: php.notes 
Request: Send a blank email to php-notes+get-25048@lists.php.net to get a copy of this message
Hi folks! Im trying to make an easier way to execute any program in background. Its almost done, but im having problems with the start of execution (PHP hangs until the completition of the background script, even with & and > /dev/null...). Im using a link validator in PHP shell that writes to a file if any of my links are unacessible. Apache 1.3.22 PHP/4.1.1 (Im not using sessions) < ? $debug="1";//Seta variável $debug para habilitá-lo ou não $script="url_checker.php";// IF ($action=="inacessíveis"){ // Se a ação for "inacessiveis" include ('inacessiveis.html'); exit; } ELSEIF ($action=="status"){ $exec = "ps | grep " . $script; $shell = $exec; IF (!$shell) { $retorno .= "Script $script não estah em execução!\n"; } ELSE { $retorno = "Script $script em execução!\n"; IF ($debug==1) { $retorno .= "\n" . $shell . "\n"; } } } ELSEIF ($action=="inicio") { $exec = "ps | grep " . $script; $shell = $exec; IF (!$shell) { IF ($debug==1) { $retorno .= "Script $script não estah em execução!\n"; $retorno .= "Inicializando o Script $script...\n"; } exec("./" . $script . " & > /dev/null"); $executa = "ps | grep " . $script; // I have tried to check from another way, // to dont make something like $blah = exec()... $shell = $executa; IF (!$executa) { $retorno .= "Script $script falhou ao inicializar!\n"; } ELSE { $retorno .= "Script $script inicializado com sucesso!\n"; IF ($debug==1) { $retorno .= "$shell\n"; } } } ELSE { $retorno = "Script $script já estah em execução!\n"; IF ($debug==1) { $retorno .= "\n" . $shell . "\n"; } } } echo "<PRE><H3>Verificador</H3>\n"; echo "<a href=?action=inicio>"; echo "[Executar Script]</a>\n"; echo "<a href=?action=status>"; echo "[Status de Execução]</a>\n"; echo "<a href=?action=inacessiveis>"; echo "[Links Inacessíveis]"; echo "</a>\n\n"; echo $retorno; echo "</PRE>\n"; ?> any ideas? TX in advance, and sorry about portuguese ... =] Auro -- http://www.php.net/manual/en/ref.exec.php http://master.php.net/manage/user-notes.php?action=edit+18331 http://master.php.net/manage/user-notes.php?action=delete+18331 http://master.php.net/manage/user-notes.php?action=reject+18331

« previous php.notes (#25048) next »