Пример #1
0
 /**
  * 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));
 }
Пример #2
0
 /**
  * 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();
 }
Пример #3
0
 /**
  * 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);
 }
Пример #4
0
 /**
  * @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();
 }