src/PTel.php
public function getOutputOf($cmd, $newline = true, $maxtimeout = 10) {
        $return = array();
        $this->recvAll();
        $this->send($cmd, $newline);
        $timestart = time();
        while (true) {
            $buff = $this->recvLine();
            $timerun = time() - $timestart;

            if (strpos($buff, $this->prompt) !== false) {
                break;
            }
            if (preg_match("/$this->page_delimiter/i", $buff)) {
                $this->send(" ", false);
                $timestart = time();
                continue;
            }

            if ($timerun >= $maxtimeout) {
                throw new TelnetException("Timeout reached while waiting to execute command: [ $cmd ]");
            }
            $return[] = $buff;
        }

        $newret = array_slice($return, 1, -1);
        $newret = implode("\r", $newret);
        return $newret;
    }
public function getOutputOf($cmd, $newline = true, $maxtimeout = 10) {
        $return = array();
        $this->recvAll();
        $this->send($cmd, $newline);
        $timestart = time();
        while (true) {
            $buff = $this->recvLine();
            $timerun = time() - $timestart;

            if (strpos($buff, $this->prompt) !== false) {
                break;
            }
            if (preg_match("/$this->page_delimiter/i", $buff)) {
                $this->send(" ", false);
                $timestart = time();
                continue;
            }

            if ($timerun >= $maxtimeout) {
                throw new TelnetException("Timeout reached while waiting to execute command: [ $cmd ]");
            }
            $return[] = $buff;
        }

        $newret = array_slice($return, 1, -1);
        $newret = implode("\r", $newret);
        return $newret;
    }
public function getOutputOf ( $ cmd , $ newline = true , $ maxtimeout = 10 ) { $ return = array ( ) ; $ this -> recvAll ( ) ; $ this -> send ( $ cmd , $ newline ) ; $ timestart = time ( ) ; while ( true ) { $ buff = $ this -> recvLine ( ) ; $ timerun = time ( ) - $ timestart ; if ( strpos ( $ buff , $ this -> prompt ) !== false ) { break ; } if ( preg_match ( "/$this->page_delimiter/i" , $ buff ) ) { $ this -> send ( " " , false ) ; $ timestart = time ( ) ; continue ; } if ( $ timerun >= $ maxtimeout ) { throw new TelnetException ( "Timeout reached while waiting to execute command: [ $cmd ]" ) ; } $ return [ ] = $ buff ; } $ newret = array_slice ( $ return , 1 , - 1 ) ; $ newret = implode ( "\r" , $ newret ) ; return $ newret ; }
Get only output of running command

@param string    $cmd            Command to execute
@param bool      $newline        Add new line character, or not
@param int       $maxtimeout     Maximum timeout to wait command execution

@throws SocketClientException    On socket communication error
@throws TelnetException          If maximum timeout reached

@return string   Result of command
Get only output of running command