Пример #1
0
 /**
  * @param $command
  *
  * @return string
  */
 public function exec($command)
 {
     $sftpDir = $this->pwd();
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $execOutput = $this->_connection->exec('cd ' . $sftpDir . ' && ' . $command);
             $this->_lastExecExitStatus = $this->_connection->getExitStatus();
             break;
         case SftpHelper::TYPE_FTP:
             // TODO: test ftp_exec on a server which supports it
             $execOutput = '';
             $res = @ftp_exec($this->_connection, 'cd ' . $sftpDir . ' && ' . $command);
             $this->_lastExecExitStatus = $res ? 0 : 1;
             break;
     }
     return $execOutput;
 }