Esempio n. 1
0
 public function exec($command, $callback = null)
 {
     if (false === $this->isConnected()) {
         $this->connectAndLogin();
     }
     //        $this->sftp->enablePTY();
     $success = $this->sftp->exec($command, $callback);
     //        $data = $this->sftp->read();
     //        if (is_callable($callback)) {
     //            $callback($data);
     //        }
     if (false === $success) {
         throw new \RuntimeException('Something went wrong: ' . "\n" . implode("\n", (array) $this->sftp->getErrors()));
     }
     $status = $this->sftp->getExitStatus();
     if ($status === false) {
         $status = -1;
     }
     return $status;
 }