public function expect($str, $cmd, $newline = true, $maxtimeout = 10) {
        if ($this->waitFor($str, $maxtimeout)) {
            $this->send($cmd, $newline);
            return true;
        }
    }