本文整理汇总了PHP中Process::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Process::close方法的具体用法?PHP Process::close怎么用?PHP Process::close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::close方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sendCommand
/**
* @param $command
* @param $string
*/
protected function _sendCommand($command, $string)
{
$process = new Process($command, $this->_globalDictionary);
$process->write($string);
$this->_raw = $process->read();
$process->close();
}
示例2: getTitle
/**
* Get the terminal title.
* @return string
*/
public static function getTitle()
{
if (!empty(self::$username)) {
$process = new Process("uname -n");
$title = self::$username . "@" . trim($process->get());
$process->close();
return $title;
} else {
return "not logged shell - how cold it be possible, uh?";
}
}
示例3: diff
/**
* Produce diff between the contents
*
* @param string left
* @param string right
*/
protected function diff($left, $right)
{
with($templ = new TempFile(), $tempr = new TempFile(), $templ->open(FILE_MODE_WRITE), $tempr->open(FILE_MODE_WRITE));
$templ->write($left);
$tempr->write($right);
$templ->close();
$tempr->close();
// TODO: Implement "diff" in userland
try {
$p = new Process(sprintf('diff -u %s %s', $templ->getURI(), $tempr->getURI()));
$p->in->close();
while (!$p->out->eof()) {
$this->out->writeLine($p->out->readLine());
}
$p->close();
} catch (IOException $e) {
$this->err->writeLine('!=> Invocation of `diff` program failed.');
$templ->unlink();
$tempr->unlink();
return;
}
$templ->unlink();
$tempr->unlink();
}
示例4: json_encode
echo '<hr>';
//$p->put(chr(21));
//var_dump($p->close());
//echo json_encode($p->getStatus());
//echo '<hr>';
// $p->put("whoami");
// $p->put(chr(13));
//echo $p->get();
usleep(500000);
echo $p->get();
$p->put("whoami");
$p->put(chr(13));
echo $p->get();
echo '<hr>';
usleep(500000);
echo $p->get();
echo '<hr>';
echo json_encode($p->getStatus());
echo '<hr>';
$p->put("ls -l");
$p->put(chr(13));
echo $p->get();
echo '<hr>';
usleep(500000);
echo $p->get();
echo '<hr>';
usleep(500000);
echo $p->get();
echo '<hr>';
echo "END " . ($p->close() ? 'NOT VALID USER OR PASSWORD' : 'SUCC LOG IN');
示例5: hugeStderr
public function hugeStderr()
{
$p = new Process($this->executable(), $this->arguments('-r', 'fputs(STDERR, str_repeat("*", 65536));'));
$err = '';
while (!$p->err->eof()) {
$err .= $p->err->read();
}
$p->close();
$this->assertEquals(65536, strlen($err));
}