/** * Send and log a smart command * * @param string $cmd * @param int $timeout */ public function sendCommand($cmd, $timeout = 15) { if (substr($this->output, -1) !== "\n") { $this->addLog("\n"); } $this->addLog($this->getPrompt() . $cmd . "\n"); $this->addLog($this->shell->sendSmartCommand($cmd, true, $timeout, true)); }
/** * Send a command and ignore the output, reset smart console * * @param $cmd */ protected function sendDumbCommand($cmd) { $this->shell->sendln($cmd); sleep(1); $this->shell->readUntilPause(1.0); $this->output($cmd); $this->shell->setSmartConsole(); }
/** * Zero out a remote file and then delete it * * @param string $fn */ protected function secureDeleteFile($fn) { $this->shell->sendSmartCommand('dd if=/dev/zero of="' . $fn . '" count=1 bs=`wc -c < "' . $fn . '"`', true, self::CMD_TIMEOUT, true); $this->shell->sendSmartCommand('rm -f "' . $fn . '"', true, self::CMD_TIMEOUT, true); }
/** * @medium * @expectedException \Bravo3\SSH\Exceptions\NotAuthenticatedException * @group server */ public function testNoAuth() { $connection = new Connection(\properties::$host, \properties::$port, new PasswordCredential(\properties::$user, \properties::$pass)); if (!$connection->connect()) { throw new \Exception("Error connecting to test server"); } $shell = new Shell($connection, new Terminal()); // exception here $shell->sendln("hello"); $this->fail(); }