phpseclib\Net\SSH1::read PHP Method

read() public method

$expect can take the form of a string literal or, if $mode == self::READ__REGEX, a regular expression.
See also: self::write()
public read ( string $expect, integer $mode = self::READ__SIMPLE ) : boolean
$expect string
$mode integer
return boolean
    function read($expect, $mode = self::READ__SIMPLE)
    {
        if (!($this->bitmap & self::MASK_LOGIN)) {
            throw new \RuntimeException('Operation disallowed prior to login()');
        }
        if (!($this->bitmap & self::MASK_SHELL) && !$this->_initShell()) {
            throw new \RuntimeException('Unable to initiate an interactive shell session');
        }
        $match = $expect;
        while (true) {
            if ($mode == self::READ__REGEX) {
                preg_match($expect, $this->interactiveBuffer, $matches);
                $match = isset($matches[0]) ? $matches[0] : '';
            }
            $pos = strlen($match) ? strpos($this->interactiveBuffer, $match) : false;
            if ($pos !== false) {
                return Strings::shift($this->interactiveBuffer, $pos + strlen($match));
            }
            $response = $this->_get_binary_packet();
            if ($response === true) {
                return Strings::shift($this->interactiveBuffer, strlen($this->interactiveBuffer));
            }
            $this->interactiveBuffer .= substr($response[self::RESPONSE_DATA], 4);
        }
    }