EXECUTAR COMANDO $command"; // return $texto; $return = ''; fwrite($stdout, $command . "\n"); fflush($stdout); while ($line = fgets($stdin)) { $return .= $line; if (strpos($line, 'result=') !== false) { if (substr($line, 0, 22) != '100 result=0 Trying...') { break; } } } $return = trim($return); return $return; }; } function agiLogWrapper() { return function ($texto) { $target = 'log' . DIRECTORY_SEPARATOR . 'log.txt'; $texto = trim($texto) . PHP_EOL; file_put_contents($target, $texto, FILE_APPEND); }; }