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($logEnabled) { return function ($texto, $options = array()) use ($logEnabled) { if ($logEnabled) { $target = 'log' . DIRECTORY_SEPARATOR . 'log.txt'; $texto .= PHP_EOL; if (isset($options['new'])) { file_put_contents($target, $texto); } else { file_put_contents($target, $texto, FILE_APPEND); } } }; }