• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP proc_close函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中proc_close函数的典型用法代码示例。如果您正苦于以下问题:PHP proc_close函数的具体用法?PHP proc_close怎么用?PHP proc_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了proc_close函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sync_object

function sync_object($object_type, $object_name)
{
    # Should only provide error information on stderr: put stdout to syslog
    $cmd = "geni-sync-wireless {$object_type} {$object_name}";
    error_log("SYNC(cmd) " . $cmd);
    $descriptors = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    $process = proc_open($cmd, $descriptors, $pipes);
    $std_output = stream_get_contents($pipes[1]);
    # Should be empty
    $err_output = stream_get_contents($pipes[2]);
    fclose($pipes[1]);
    fclose($pipes[2]);
    $proc_value = proc_close($process);
    $full_output = $std_output . $err_output;
    foreach (split("\n", $full_output) as $line) {
        if (strlen(trim($line)) == 0) {
            continue;
        }
        error_log("SYNC(output) " . $line);
    }
    if ($proc_value != RESPONSE_ERROR::NONE) {
        error_log("WIRELESS SYNC error: {$proc_value}");
    }
    return $proc_value;
}
开发者ID:ahelsing,项目名称:geni-portal,代码行数:25,代码来源:wireless_operations.php


示例2: __construct

 /**
  * Constructor.
  *
  * @param Horde_Vcs_Base $rep  A repository object.
  * @param string $dn           Path to the directory.
  * @param array $opts          Any additional options:
  *
  * @throws Horde_Vcs_Exception
  */
 public function __construct(Horde_Vcs_Base $rep, $dn, $opts = array())
 {
     parent::__construct($rep, $dn, $opts);
     $cmd = $rep->getCommand() . ' ls ' . escapeshellarg($rep->sourceroot . $this->_dirName);
     $dir = proc_open($cmd, array(1 => array('pipe', 'w'), 2 => array('pipe', 'w')), $pipes);
     if (!$dir) {
         throw new Horde_Vcs_Exception('Failed to execute svn ls: ' . $cmd);
     }
     if ($error = stream_get_contents($pipes[2])) {
         proc_close($dir);
         throw new Horde_Vcs_Exception($error);
     }
     /* Create two arrays - one of all the files, and the other of all the
      * dirs. */
     $errors = array();
     while (!feof($pipes[1])) {
         $line = chop(fgets($pipes[1], 1024));
         if (!strlen($line)) {
             continue;
         }
         if (substr($line, 0, 4) == 'svn:') {
             $errors[] = $line;
         } elseif (substr($line, -1) == '/') {
             $this->_dirs[] = substr($line, 0, -1);
         } else {
             $this->_files[] = $rep->getFile($this->_dirName . '/' . $line);
         }
     }
     proc_close($dir);
 }
开发者ID:jubinpatel,项目名称:horde,代码行数:39,代码来源:Svn.php


示例3: GetMime

 /**
  * Gets the mime type for a blob
  *
  * @param GitPHP_Blob $blob blob
  * @return string mime type
  */
 public function GetMime($blob)
 {
     if (!$blob) {
         return false;
     }
     $data = $blob->GetData();
     if (empty($data)) {
         return false;
     }
     $descspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'));
     $proc = proc_open('file -b --mime -', $descspec, $pipes);
     if (is_resource($proc)) {
         fwrite($pipes[0], $data);
         fclose($pipes[0]);
         $mime = stream_get_contents($pipes[1]);
         fclose($pipes[1]);
         proc_close($proc);
         if ($mime && strpos($mime, '/')) {
             if (strpos($mime, ';')) {
                 $mime = strtok($mime, ';');
             }
             return $mime;
         }
     }
     return false;
 }
开发者ID:fboender,项目名称:gitphp,代码行数:32,代码来源:FileMimeType_FileExe.class.php


示例4: collectProcessGarbage

 private function collectProcessGarbage()
 {
     foreach ($this->processes as $key => $procHandle) {
         $info = proc_get_status($procHandle);
         if ($info["running"]) {
             continue;
         }
         $this->defunctProcessCount--;
         proc_close($procHandle);
         unset($this->processes[$key]);
         if ($this->expectedFailures > 0) {
             $this->expectedFailures--;
             continue;
         }
         if (!$this->stopPromisor) {
             $this->spawn();
         }
     }
     // If we've reaped all known dead processes we can stop checking
     if (empty($this->defunctProcessCount)) {
         \Amp\disable($this->procGarbageWatcher);
     }
     if ($this->stopPromisor && empty($this->processes)) {
         \Amp\cancel($this->procGarbageWatcher);
         if ($this->stopPromisor !== true) {
             \Amp\immediately([$this->stopPromisor, "succeed"]);
         }
         $this->stopPromisor = true;
     }
 }
开发者ID:beentrill,项目名称:aerys,代码行数:30,代码来源:WatcherProcess.php


示例5: run

 /**
  * Execute the given command
  *
  * @param string $command Command to execute
  * @param array  $args    Arguments for command
  *
  * @return mixed $return Command output
  */
 public function run($command, $args = null)
 {
     Output::msg('Executing command: "' . $command . '"');
     // filter the command
     $command = escapeshellcmd($command);
     $descSpec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
     $pipes = null;
     $return = null;
     $process = proc_open($command, $descSpec, $pipes);
     if (is_resource($process)) {
         $return = stream_get_contents($pipes[1]);
         if (empty($return)) {
             // probably some sort of error
             if (is_resource($pipes[2])) {
                 $err = trim(stream_get_contents($pipes[2]));
                 fclose($pipes[2]);
                 throw new \Exception($err);
             }
         }
         fclose($pipes[1]);
         $returnCode = proc_close($process);
         Output::msg("Execution result:\n" . $return);
     }
     return $return;
 }
开发者ID:robertbasic,项目名称:usher,代码行数:33,代码来源:Execute.php


示例6: execute

 /**
  * Execute this command.
  *
  * @return int  Error code returned by the subprocess.
  *
  * @task command
  */
 public function execute()
 {
     $command = $this->command;
     $profiler = PhutilServiceProfiler::getInstance();
     $call_id = $profiler->beginServiceCall(array('type' => 'exec', 'subtype' => 'passthru', 'command' => $command));
     $spec = array(STDIN, STDOUT, STDERR);
     $pipes = array();
     if ($command instanceof PhutilCommandString) {
         $unmasked_command = $command->getUnmaskedString();
     } else {
         $unmasked_command = $command;
     }
     $env = $this->env;
     $cwd = $this->cwd;
     $options = array();
     if (phutil_is_windows()) {
         // Without 'bypass_shell', things like launching vim don't work properly,
         // and we can't execute commands with spaces in them, and all commands
         // invoked from git bash fail horridly, and everything is a mess in
         // general.
         $options['bypass_shell'] = true;
     }
     $trap = new PhutilErrorTrap();
     $proc = @proc_open($unmasked_command, $spec, $pipes, $cwd, $env, $options);
     $errors = $trap->getErrorsAsString();
     $trap->destroy();
     if (!is_resource($proc)) {
         throw new Exception(pht('Failed to passthru %s: %s', 'proc_open()', $errors));
     }
     $err = proc_close($proc);
     $profiler->endServiceCall($call_id, array('err' => $err));
     return $err;
 }
开发者ID:barcelonascience,项目名称:libphutil,代码行数:40,代码来源:PhutilExecPassthru.php


示例7: printFax

 function printFax($fax_id)
 {
     $data = $GLOBALS['hylax_storage']->getFaxData($fax_id);
     $command = $GLOBALS['conf']['fax']['print'];
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     /* Set up the process. */
     $process = proc_open($command, $descriptorspec, $pipes);
     if (!is_resource($process)) {
         return PEAR::raiseError('fail');
     }
     fwrite($pipes[0], $data);
     fclose($pipes[0]);
     $output = '';
     while (!feof($pipes[1])) {
         $output .= fgets($pipes[1], 1024);
     }
     fclose($pipes[1]);
     $stderr = '';
     while (!feof($pipes[2])) {
         $stderr .= fgets($pipes[2], 1024);
     }
     fclose($pipes[2]);
     proc_close($process);
     if ($stderr) {
         return PEAR::raiseError($stderr);
     }
     return true;
 }
开发者ID:horde,项目名称:horde,代码行数:28,代码来源:Hylax.php


示例8: evaluate

 /**
  * Evaluates the constraint for parameter $other. Returns TRUE if the
  * constraint is met, FALSE otherwise.
  *
  * @param mixed $other Filename of the image to compare.
  * @return bool
  * @abstract
  */
 public function evaluate($other)
 {
     if (!is_string($other) || !is_file($other) || !is_readable($other)) {
         throw new ezcBaseFileNotFoundException($other);
     }
     $descriptors = array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w'));
     $command = sprintf('compare -metric MAE %s %s null:', escapeshellarg($this->filename), escapeshellarg($other));
     $imageProcess = proc_open($command, $descriptors, $pipes);
     // Close STDIN pipe
     fclose($pipes[0]);
     $errorString = '';
     // Read STDERR
     do {
         $errorString .= rtrim(fgets($pipes[2], 1024), "\n");
     } while (!feof($pipes[2]));
     $resultString = '';
     // Read STDOUT
     do {
         $resultString .= rtrim(fgets($pipes[1], 1024), "\n");
     } while (!feof($pipes[1]));
     // Wait for process to terminate and store return value
     $return = proc_close($imageProcess);
     // Some versions output to STDERR
     if (empty($resultString) && !empty($errorString)) {
         $resultString = $errorString;
     }
     // Different versuions of ImageMagick seem to output "dB" or not
     if (preg_match('/([\\d.,e]+)(\\s+dB)?/', $resultString, $match)) {
         $this->difference = (int) $match[1];
         return $this->difference <= $this->delta;
     }
     return false;
 }
开发者ID:naderman,项目名称:pflow,代码行数:41,代码来源:image.php


示例9: executeCommand

 /**
  * Executes shell commands.
  * @param array $args
  * @return bool Indicates success
  */
 public function executeCommand($args = array())
 {
     $this->lastOutput = array();
     $command = call_user_func_array('sprintf', $args);
     if ($this->quiet) {
         $this->logger->log('Executing: ' . $command);
     }
     $status = 0;
     $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     $pipes = array();
     $process = proc_open($command, $descriptorSpec, $pipes, dirname($this->buildPath), null);
     if (is_resource($process)) {
         fclose($pipes[0]);
         $this->lastOutput = stream_get_contents($pipes[1]);
         $this->lastError = stream_get_contents($pipes[2]);
         fclose($pipes[1]);
         fclose($pipes[2]);
         $status = proc_close($process);
     }
     $this->lastOutput = array_filter(explode(PHP_EOL, $this->lastOutput));
     $shouldOutput = $this->logExecOutput && ($this->verbose || $status != 0);
     if ($shouldOutput && !empty($this->lastOutput)) {
         $this->logger->log($this->lastOutput);
     }
     if (!empty($this->lastError)) {
         $this->logger->log("[0;31m" . $this->lastError . "[0m", LogLevel::ERROR);
     }
     $rtn = false;
     if ($status == 0) {
         $rtn = true;
     }
     return $rtn;
 }
开发者ID:kukupigs,项目名称:PHPCI,代码行数:38,代码来源:BaseCommandExecutor.php


示例10: stream

 public function stream(Git_HTTP_Command $command)
 {
     $cwd = '/tmp';
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     if (ForgeConfig::get('sys_logger_level') == Logger::DEBUG) {
         $descriptorspec[2] = array('file', ForgeConfig::get('codendi_log') . '/git_http_error_log', 'a');
     }
     $pipes = array();
     $this->logger->debug('Command: ' . $command->getCommand());
     $this->logger->debug('Environment: ' . print_r($command->getEnvironment(), true));
     $process = proc_open($command->getCommand(), $descriptorspec, $pipes, $cwd, $command->getEnvironment());
     if (is_resource($process)) {
         if ($_SERVER['REQUEST_METHOD'] == 'POST') {
             fwrite($pipes[0], file_get_contents('php://input'));
         }
         fclose($pipes[0]);
         $first = true;
         while ($result = stream_get_contents($pipes[1], self::CHUNK_LENGTH)) {
             if ($first) {
                 list($headers, $body) = http_split_header_body($result);
                 foreach (explode("\r\n", $headers) as $header) {
                     header($header);
                 }
                 file_put_contents('php://output', $body);
             } else {
                 file_put_contents('php://output', $result);
             }
             $first = false;
         }
         fclose($pipes[1]);
         $return_value = proc_close($process);
     }
 }
开发者ID:pombredanne,项目名称:tuleap,代码行数:33,代码来源:Wrapper.class.php


示例11: render

 public function render()
 {
     // Generate the DOT source code, and write to a file.
     $dot = new \Tabulate\Template('erd/erd.twig');
     $dot->tables = $this->tables;
     $dot->selectedTables = $this->selectedTables;
     $dotCode = $dot->render();
     $tmpFilePath = Config::storageDirTmp('erd/' . uniqid());
     $dotFile = $tmpFilePath . '/erd.dot';
     $pngFile = $tmpFilePath . '/erd.png';
     file_put_contents($dotFile, $dotCode);
     // Generate the image.
     $cmd = Config::dotCommand() . ' -Tpng -o' . escapeshellarg($pngFile) . ' ' . escapeshellarg($dotFile);
     $ds = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
     $pipes = false;
     $proc = proc_open($cmd, $ds, $pipes, Config::storageDirTmp('erd'), array());
     fclose($pipes[0]);
     $out = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $err = stream_get_contents($pipes[2]);
     fclose($pipes[2]);
     proc_close($proc);
     if (!empty($err)) {
         throw new \Exception("Error generating graph image. {$err}");
     }
     // Send the image.
     header('Content-Type:image/png');
     echo file_get_contents($pngFile);
     // Clean up.
     \Tabulate\File::rmdir($tmpFilePath);
 }
开发者ID:tabulate,项目名称:tabulate3,代码行数:31,代码来源:ErdController.php


示例12: execute

 private function execute($args, $pipe_stdout, $cwd_override = null)
 {
     $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     $cwd = $cwd_override != NULL ? $cwd_override : $this->cwd;
     $cmd = join(' ', array_map('escapeshellarg', $args));
     $proc = proc_open($cmd, $descriptorspec, $pipes, $cwd, array('LANG' => 'en_US.UTF-8'));
     if (!is_resource($proc)) {
         $errors = error_get_last();
         $this->log->error("{$cmd} failed: {$errors['type']} {$errors['message']}");
         throw new Exception($errors['message']);
     }
     fclose($pipes[0]);
     if ($pipe_stdout) {
         $output = stream_get_contents($pipes[1]);
     } else {
         fpassthru($pipes[1]);
         $output = null;
     }
     $err = stream_get_contents($pipes[2]);
     $retval = proc_close($proc);
     if ($retval != 0) {
         $this->log->error("{$cmd} failed: {$retval} {$output} {$err}");
         throw new Exception($err);
     }
     return $output;
 }
开发者ID:kukogit,项目名称:omegaup,代码行数:26,代码来源:Git.php


示例13: cs2cs_core2

function cs2cs_core2($lat, $lon, $to)
{
    $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
    if (mb_eregi('^[a-z0-9_ ,.\\+\\-=]*$', $to) == 0) {
        die("invalid arguments in command: " . $to . "\n");
    }
    $command = CS2CS . " +proj=latlong +ellps=WGS84 +to " . $to;
    $process = proc_open($command, $descriptorspec, $pipes);
    if (is_resource($process)) {
        fwrite($pipes[0], $lon . " " . $lat);
        fclose($pipes[0]);
        $stdout = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $stderr = stream_get_contents($pipes[2]);
        fclose($pipes[2]);
        //
        // $procstat = proc_get_status($process);
        //
        // neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11,
        // see http://bugs.php.net/bug.php?id=32533
        //
        // as temporary (?) workaround, check stderr output.
        // (Vinnie, 2006-02-09)
        if ($stderr) {
            die("proc_open() failed:<br />command='{$command}'<br />stderr='" . $stderr . "'");
        }
        proc_close($process);
        return mb_split("\t|\n| ", mb_trim($stdout));
    } else {
        die("proc_open() failed, command={$command}\n");
    }
}
开发者ID:kojoty,项目名称:opencaching-pl,代码行数:32,代码来源:cs2cs.inc.php


示例14: __invoke

 /**
  * Launch PHP's built-in web server for this specific WordPress installation.
  *
  * Uses `php -S` to launch a web server serving the WordPress webroot.
  * <http://php.net/manual/en/features.commandline.webserver.php>
  *
  * ## OPTIONS
  *
  * [--host=<host>]
  * : The hostname to bind the server to.
  * ---
  * default: localhost
  * ---
  *
  * [--port=<port>]
  * : The port number to bind the server to.
  * ---
  * default: 8080
  * ---
  *
  * [--docroot=<path>]
  * : The path to use as the document root.
  *
  * [--config=<file>]
  * : Configure the server with a specific .ini file.
  *
  * ## EXAMPLES
  *
  *     # Make the instance available on any address (with port 8080)
  *     $ wp server --host=0.0.0.0
  *     PHP 5.6.9 Development Server started at Tue May 24 01:27:11 2016
  *     Listening on http://0.0.0.0:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  *     # Run on port 80 (for multisite)
  *     $ sudo wp server --host=localhost.localdomain --port=80
  *     PHP 5.6.9 Development Server started at Tue May 24 01:30:06 2016
  *     Listening on http://localhost1.localdomain1:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  *     # Configure the server with a specific .ini file
  *     $ wp server --config=development.ini
  *     PHP 7.0.9 Development Server started at Mon Aug 22 12:09:04 2016
  *     Listening on http://localhost:8080
  *     Document root is /
  *     Press Ctrl-C to quit.
  *
  * @when before_wp_load
  */
 function __invoke($_, $assoc_args)
 {
     $min_version = '5.4';
     if (version_compare(PHP_VERSION, $min_version, '<')) {
         WP_CLI::error("The `wp server` command requires PHP {$min_version} or newer.");
     }
     $defaults = array('host' => 'localhost', 'port' => 8080, 'docroot' => false, 'config' => get_cfg_var('cfg_file_path'));
     $assoc_args = array_merge($defaults, $assoc_args);
     $docroot = $assoc_args['docroot'];
     if (!$docroot) {
         $config_path = WP_CLI::get_runner()->project_config_path;
         if (!$config_path) {
             $docroot = ABSPATH;
         } else {
             $docroot = dirname($config_path);
         }
     }
     $cmd = \WP_CLI\Utils\esc_cmd('%s -S %s -t %s -c %s %s', PHP_BINARY, $assoc_args['host'] . ':' . $assoc_args['port'], $docroot, $assoc_args['config'], \WP_CLI\Utils\extract_from_phar(WP_CLI_ROOT . '/php/router.php'));
     $descriptors = array(STDIN, STDOUT, STDERR);
     // https://bugs.php.net/bug.php?id=60181
     $options = array();
     if (\WP_CLI\Utils\is_windows()) {
         $options["bypass_shell"] = TRUE;
     }
     exit(proc_close(proc_open($cmd, $descriptors, $pipes, NULL, NULL, $options)));
 }
开发者ID:wp-cli,项目名称:wp-cli,代码行数:77,代码来源:server.php


示例15: scan

 protected function scan($fileView, $filepath)
 {
     $this->status = new Status();
     $fhandler = $this->getFileHandle($fileView, $filepath);
     \OCP\Util::writeLog('files_antivirus', 'Exec scan: ' . $filepath, \OCP\Util::DEBUG);
     // using 2>&1 to grab the full command-line output.
     $cmd = escapeshellcmd($this->avPath) . " - 2>&1";
     $descriptorSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"));
     $pipes = array();
     $process = proc_open($cmd, $descriptorSpec, $pipes);
     if (!is_resource($process)) {
         fclose($fhandler);
         throw new \RuntimeException('Error starting process');
     }
     // write to stdin
     $shandler = $pipes[0];
     while (!feof($fhandler)) {
         $chunk = fread($fhandler, $this->chunkSize);
         fwrite($shandler, $chunk);
     }
     fclose($shandler);
     fclose($fhandler);
     $output = stream_get_contents($pipes[1]);
     fclose($pipes[1]);
     $result = proc_close($process);
     $this->status->parseResponse($output, $result);
     return $this->status->getNumericStatus();
 }
开发者ID:WYSAC,项目名称:oregon-owncloud,代码行数:28,代码来源:local.php


示例16: changePwd

 public function changePwd($newPwd)
 {
     $ldapObj = new Lucid_LDAP($this->configFile);
     $ldapObj->bind($this->username, $this->password);
     list($entry, $dn) = $ldapObj->searchUser($this->username, array("sAMAccountName"));
     $ldapObj->destroy();
     $this->loggerObj->log("Changing password for {$this->username}");
     $oldPwdEnc = base64_encode(adifyPw($this->password));
     $newPwdEnc = base64_encode(adifyPw($newPwd));
     $tmpPath = getConfig("tmpPath");
     $tmpName = tempnam($tmpPath, "ldap-");
     try {
         $tmpFile = fopen($tmpName, "w+");
         fwrite($tmpFile, $this->password);
         fclose($tmpFile);
         $cmd = "ldapmodify -H {$ldapObj->url} -D '{$dn}' -x -y {$tmpName}";
         $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
         $child = proc_open(escapeshellcmd($cmd), $descriptorspec, $pipes);
         $ldif_file = array("dn: {$dn}", "changetype: modify", "delete: unicodePwd", "unicodePwd:: {$oldPwdEnc}", "-", "add: unicodePwd", "unicodePwd:: {$newPwdEnc}", "-");
         fwrite($pipes[0], implode("\n", $ldif_file) . "\n");
         fclose($pipes[0]);
         $output1 = stream_get_contents($pipes[1]);
         $output2 = stream_get_contents($pipes[2]);
         fclose($pipes[1]);
         fclose($pipes[2]);
         $status = proc_close($child);
         $this->loggerObj->log("LDAPModify exited with status: {$status}");
         $this->loggerObj->log("LDAPModify Output: {$output1}\n {$output2}");
         return array($status, $output2);
     } finally {
         if ($tmpFile) {
             unlink($tmpName);
         }
     }
 }
开发者ID:sriraamas,项目名称:simple-ldap-manager,代码行数:35,代码来源:user.php


示例17: stream_close

 /**
  *
  */
 public function stream_close()
 {
     if (is_resource($this->process)) {
         $this->subprocess_write(self::COMMAND_EXIT);
         proc_close($this->process);
     }
 }
开发者ID:calcinai,项目名称:php-mmap,代码行数:10,代码来源:StreamWrapper.php


示例18: pleac_Controlling_Input_and_Output_of_Another_Program

function pleac_Controlling_Input_and_Output_of_Another_Program()
{
    // Connect to input and output of a process.
    $proc = proc_open($program, array(0 => array('pipe', 'r'), 1 => array('pipe', 'w')), $pipes);
    if (is_resource($proc)) {
        fwrite($pipes[0], "here's your input\n");
        fclose($pipes[0]);
        echo stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        $result_code = proc_close($proc);
        echo "{$result_code}\n";
    }
    // -----------------------------
    $all = array();
    $outlines = array();
    $errlines = array();
    exec("( {$cmd} | sed -e 's/^/stdout: /' ) 2>&1", $all);
    foreach ($all as $line) {
        $pos = strpos($line, 'stdout: ');
        if ($pos !== false && $pos == 0) {
            $outlines[] = substr($line, 8);
        } else {
            $errlines[] = $line;
        }
    }
    print "STDOUT:\n";
    print_r($outlines);
    print "\n";
    print "STDERR:\n";
    print_r($errlines);
    print "\n";
}
开发者ID:Halfnhav4,项目名称:pfff,代码行数:32,代码来源:Controlling_Input_and_Output_of_Another_Program.php


示例19: phutil_passthru

/**
 * Execute a command which takes over stdin, stdout and stderr, similar to
 * passthru(), but which preserves TTY semantics, escapes arguments, and is
 * traceable.
 *
 * @param  string  sprintf()-style command pattern to execute.
 * @param  ...     Arguments to sprintf pattern.
 * @return int     Return code.
 * @group exec
 */
function phutil_passthru($cmd)
{
    $args = func_get_args();
    $command = call_user_func_array('csprintf', $args);
    $profiler = PhutilServiceProfiler::getInstance();
    $call_id = $profiler->beginServiceCall(array('type' => 'exec', 'subtype' => 'passthru', 'command' => $command));
    $spec = array(STDIN, STDOUT, STDERR);
    $pipes = array();
    if (phutil_is_windows()) {
        // Without 'bypass_shell', things like launching vim don't work properly,
        // and we can't execute commands with spaces in them, and all commands
        // invoked from git bash fail horridly, and everything is a mess in general.
        $options = array('bypass_shell' => true);
        $proc = @proc_open($command, $spec, $pipes, null, null, $options);
    } else {
        $proc = @proc_open($command, $spec, $pipes);
    }
    if ($proc === false) {
        $err = 1;
    } else {
        $err = proc_close($proc);
    }
    $profiler->endServiceCall($call_id, array('err' => $err));
    return $err;
}
开发者ID:chaozhang80,项目名称:tool-package,代码行数:35,代码来源:execx.php


示例20: setDomainAddress

function setDomainAddress($domain, $address, $server, $ttl = 86400)
{
    $process = proc_open('/usr/bin/nsupdate', array(array('pipe', 'r'), array('pipe', 'w'), array('pipe', 'w')), $pipes);
    if (is_resource($process)) {
        fwrite($pipes[0], "server {$server}\n");
        fwrite($pipes[0], "update delete {$domain}.\n");
        if ($address !== false) {
            fwrite($pipes[0], "update add {$domain}. {$ttl} IN A {$address}\n");
        }
        fwrite($pipes[0], "\n");
        fclose($pipes[0]);
        $result = true;
        if (fgetc($pipes[1]) !== false) {
            $result = false;
        }
        fclose($pipes[1]);
        if (fgetc($pipes[2]) !== false) {
            $result = false;
        }
        fclose($pipes[2]);
        proc_close($process);
        return $result;
    }
    return false;
}
开发者ID:ragi79,项目名称:Textcube,代码行数:25,代码来源:nsupdate.php



注:本文中的proc_close函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP proc_get_status函数代码示例发布时间:2022-05-15
下一篇:
PHP probe_url函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap