当前位置: 首页>>代码示例>>PHP>>正文


PHP ssh2_scp_send函数代码示例

本文整理汇总了PHP中ssh2_scp_send函数的典型用法代码示例。如果您正苦于以下问题:PHP ssh2_scp_send函数的具体用法?PHP ssh2_scp_send怎么用?PHP ssh2_scp_send使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了ssh2_scp_send函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: send

 /**
  *
  * @param string $remoteFileName            
  * @param string $localFilename            
  * @throws \Exception
  */
 public function send($remoteFileName, $localFilename)
 {
     if (empty($this->session)) {
         throw new \Exception("Veuillez vous connecter au serveur avant de déposer un fichier");
     }
     ssh2_scp_send($this->session, $localFilename, $remoteFileName);
 }
开发者ID:dsi-agpt,项目名称:minibus,代码行数:13,代码来源:ScpClient.php

示例2: store

 /**
  * @inheritdoc
  */
 public function store(File $file)
 {
     if ($this->session === null) {
         $this->connect();
     }
     return ssh2_scp_send($this->session, $file->getLocation(), $this->remoteLocation . DIRECTORY_SEPARATOR . $file->getName());
 }
开发者ID:p13eater,项目名称:backup-lib,代码行数:10,代码来源:SSH2.php

示例3: put

 public function put($local, $remote)
 {
     //make sure we are connected
     $this->connect();
     $this->plugin->Logger('nutshell.plugin.transfer.scp')->info(sprintf('Uploading to remote file %s...', $remote));
     if (is_resource($local)) {
         throw new TransferException(sprintf('SCP of file handle has not been implemented.', $remote));
     } else {
         if (is_string($local)) {
             //upload using file name.
             $this->plugin->Logger('nutshell.plugin.transfer.scp')->debug('Uploading using local file path.');
             //check for file existence
             if (!is_readable($local)) {
                 throw new TransferException(sprintf('File %s not be found or not accessible', $local));
             }
             //transfers the file
             if (!ssh2_scp_send($this->connection, $local, $remote, 0644)) {
                 throw new TransferException(sprintf('Transfer of file %s to %s failed', $local, $remote));
             }
         } else {
             throw new TransferException(sprintf('Invalid parameter %s: expected string or file handle', parse_r($local, true)));
         }
     }
     $this->plugin->Logger('nutshell.plugin.transfer.scp')->info(sprintf('File transfered to %s successfully.', $remote));
 }
开发者ID:CoatesDigital,项目名称:nutshell,代码行数:25,代码来源:SCP.php

示例4: coneccionSshImg

 function coneccionSshImg($ids, $mBanner, $config)
 {
     $porciones = explode(",", $ids);
     foreach ($porciones as $value) {
         $dataBanner = $mBanner->select($value);
         $avanzado = ROOT_IMG_DINAMIC . '/banner/avanzado/' . $dataBanner["ImgAvanzado"];
         $basico128 = ROOT_IMG_DINAMIC . '/banner/basico128/' . $dataBanner["ImgBasico128"];
         $basico240 = ROOT_IMG_DINAMIC . '/banner/basico240/' . $dataBanner["ImgBasico240"];
         $basico360 = ROOT_IMG_DINAMIC . '/banner/basico360/' . $dataBanner["ImgBasico360"];
         if (!function_exists("ssh2_connect")) {
             die("function ssh2_connect doesn't exist");
         }
         if (!($con = ssh2_connect($config['app']['server'], $config['app']['puerto']))) {
             echo "fail: unable to establish connection\n";
         } else {
             if (!ssh2_auth_password($con, $config['app']['user'], $config['app']['pass'])) {
                 echo "fail: unable to authenticate\n";
             } else {
                 ssh2_scp_send($con, $avanzado, $config['app']['rutaImg'] . 'banner/avanzado/' . $dataBanner["ImgAvanzado"], 0644);
                 ssh2_scp_send($con, $basico128, $config['app']['rutaImg'] . 'banner/basico128/' . $dataBanner["ImgBasico128"], 0644);
                 ssh2_scp_send($con, $basico240, $config['app']['rutaImg'] . 'banner/basico240/' . $dataBanner["ImgBasico240"], 0644);
                 ssh2_scp_send($con, $basico360, $config['app']['rutaImg'] . 'banner/basico360/' . $dataBanner["ImgBasico360"], 0644);
             }
             ssh2_exec($con, 'exit');
         }
     }
     return;
 }
开发者ID:josmel,项目名称:movistar,代码行数:28,代码来源:SetBannerGroup.php

示例5: _save

 /**
  * Saves the image to the remote server. If the folder structure doesn't exist, create it.
  *
  * @param string $relFilename	path (with filename) from the CDN root
  * @param string $tempfile		temp file name to upload
  * @return bool
  */
 protected function _save($relFilename, $tempfile)
 {
     $base = Mage::getStoreConfig('imagecdn/ftp/base');
     $remotePath = str_replace('\\', '/', str_replace('//', '/', '/' . $base . '/' . $relFilename));
     ssh2_sftp_mkdir(ssh2_sftp($this->auth()), substr($remotePath, 0, strrpos($remotePath, '/')), 0777, true);
     $result = ssh2_scp_send($this->auth(), $tempfile, $remotePath, 0644);
     return $result ? true : false;
 }
开发者ID:shebin512,项目名称:Magento_Zoff,代码行数:15,代码来源:Sftp.php

示例6: send

 function send($srcFilePath, $destFilePath)
 {
     if (ssh2_scp_send($this->ssh_connection, $srcFilePath, $destFilePath, 0644)) {
         echo "uploading {$srcFilePath} ok!\n";
     } else {
         echo "uploading {$srcFilePath} error!\n please check!\n";
     }
 }
开发者ID:jamesduan,项目名称:etbackuptool,代码行数:8,代码来源:SSHHost.php

示例7: copy

 public function copy($source_pathname, $destination_pathname, $mime = NULL, $filename = NULL, $extras = array())
 {
     if (count($source_pathname) == 0 || count($destination_pathname) == 0) {
         return;
     }
     if ($destination_pathname[0] != '/') {
         $destination_pathname = $this->cwd . $destination_pathname;
     }
     ssh2_scp_send($this->session, $source_pathname, $destination_pathname);
 }
开发者ID:enormego,项目名称:EightPHP,代码行数:10,代码来源:ssh.php

示例8: scpSend

 public function scpSend($localFile, $remoteFile, $createMode = 0644)
 {
     $this->logs[] = '$ scp ' . $localFile . ' remote:' . $remoteFile;
     $result = ssh2_scp_send($this->connection, $localFile, $remoteFile, $createMode);
     if (!$result) {
         $this->logs[] = 'Send a file via SCP failed.';
         return false;
     }
     return true;
 }
开发者ID:nouphet,项目名称:xoops-tpSocialMedia,代码行数:10,代码来源:Ssh2.php

示例9: getSFTPPath

 /**
  * Find XE installed path on sftp
  */
 function getSFTPPath()
 {
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) {
         $ftp_info->ftp_port = '22';
     }
     $connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
     if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $sftp = ssh2_sftp($connection);
     // create temp file
     $pin = $_SERVER['REQUEST_TIME'];
     FileHandler::writeFile('./files/cache/ftp_check', $pin);
     // create path candidate
     $xe_path = _XE_PATH_;
     $path_info = array_reverse(explode('/', _XE_PATH_));
     array_pop($path_info);
     // remove last '/'
     $path_candidate = array();
     $temp = '';
     foreach ($path_info as $path) {
         $temp = '/' . $path . $temp;
         $path_candidate[] = $temp;
     }
     // try
     foreach ($path_candidate as $path) {
         // upload check file
         if (!@ssh2_scp_send($connection, FileHandler::getRealPath('./files/cache/ftp_check'), $path . 'ftp_check.html')) {
             continue;
         }
         // get check file
         $result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
         // delete temp check file
         @ssh2_sftp_unlink($sftp, $path . 'ftp_check.html');
         // found
         if ($result == $pin) {
             $found_path = $path;
             break;
         }
     }
     FileHandler::removeFile('./files/cache/ftp_check', $pin);
     if ($found_path) {
         $this->add('found_path', $found_path);
     }
 }
开发者ID:conory,项目名称:rhymix,代码行数:52,代码来源:admin.admin.model.php

示例10: upload

 public function upload($localFilename, $remoteFilename)
 {
     if (!file_exists($localFilename)) {
         throw new ConnectionException('File does not exist');
     }
     if (!is_resource($this->sftpResource)) {
         throw new ConnectionException('Connection is not open');
     }
     $scpResult = @ssh2_scp_send($this->sshResource, $localFilename, $this->getRemotePath($remoteFilename));
     if ($scpResult) {
         return $this;
     } else {
         throw new ConnectionException('Unable to upload file');
     }
 }
开发者ID:mazhuravlev,项目名称:file-transfer,代码行数:15,代码来源:SFTPConnection.php

示例11: main

 public function main()
 {
     $this->determineEndpoints();
     $connection = ssh2_connect($this->host, $this->port);
     if (is_null($connection)) {
         throw new BuildException("Could not establish connection to " . $this->host . ":" . $this->port . "!");
     }
     $could_auth = ssh2_auth_password($connection, $this->username, $this->password);
     if (!$could_auth) {
         throw new BuildException("Could not authenticate connection!");
     }
     if (!is_null($this->mode)) {
         ssh2_scp_send($connection, $this->localEndpoint, $this->remoteEndpoint, $this->mode);
     } else {
         ssh2_scp_send($connection, $this->localEndpoint, $this->remoteEndpoint);
     }
 }
开发者ID:umesecke,项目名称:phing,代码行数:17,代码来源:ScpTask.php

示例12: put

 public function put($local, $remote, $file_mode = 0644, $auto_mkdir = true, $dir_mode = 0644)
 {
     $dir = dirname($remote);
     $sftp = ssh2_sftp($this->conn_);
     $remote_dir = "ssh2.sftp://{$sftp}/{$dir}";
     if (!file_exists($remote_dir)) {
         if ($auto_mkdir) {
             $rc = mkdir($remote_dir, $dir_mode, true);
             if (false === $rc) {
                 $this->setErr_(-1, 'failed to mkdir ' . $dir);
                 return false;
             }
         } else {
             return false;
         }
     }
     return ssh2_scp_send($this->conn_, $local, $remote, $file_mode);
 }
开发者ID:nicevoice,项目名称:yhtx,代码行数:18,代码来源:Sftp.php

示例13: write

 public function write($data, $remote_path)
 {
     global $config;
     switch ($this->type) {
         case 'sftp':
             $sftp = ssh2_sftp($this->connection);
             file_write('ssh2.sftp://' . $sftp . $remote_path, $data, true);
             break;
         case 'scp':
             $file = tempnam($config['tmp'], 'tinyboard-scp');
             // Write to temp file
             file_write($file, $data);
             ssh2_scp_send($this->connection, $file, $remote_path, 0755);
             break;
         default:
             error('Unknown send method.');
     }
 }
开发者ID:0151n,项目名称:vichan,代码行数:18,代码来源:remote.php

示例14: run_script_on_server

function run_script_on_server($script, $server, $user, $public_key_file, $private_key_file)
{
    $con = ssh2_connect($server);
    if ($con === false) {
        return array(false, false);
    }
    $result = ssh2_auth_pubkey_file($con, $user, $public_key_file, $private_key_file);
    if (!$result) {
        return array(false, false);
    }
    $remote_script = basename($script);
    $result = ssh2_scp_send($con, $script, $remote_script, 0700);
    if (!$result) {
        return array(false, false);
    }
    $io_stream = ssh2_exec($con, "( ./{$remote_script} ) 2>&1; echo \$?");
    if ($io_stream) {
        stream_set_blocking($io_stream, true);
        $output = '';
        while (true) {
            $line = fgets($io_stream);
            if ($line === false) {
                break;
            }
            $output .= $line;
        }
        fclose($io_stream);
        $output = rtrim($output);
        $last_newline_index = strrpos($output, "\n");
        $status_code = intval(substr($output, $last_newline_index + 1));
        $output = substr($output, 0, $last_newline_index);
    } else {
        $output = false;
        $status_code = false;
    }
    $sftp_con = ssh2_sftp($con);
    if ($sftp_con) {
        ssh2_sftp_unlink($sftp_con, $remote_script);
    }
    return array($output, $status_code);
}
开发者ID:cleberps,项目名称:linux-learn-map,代码行数:41,代码来源:check.php

示例15: sftp_walk

function sftp_walk($con, $sftp, $local_dir, $remote_dir)
{
    $dir = opendir($local_dir);
    ssh2_sftp_mkdir($sftp, $remote_dir, 0755, true);
    while (($file = readdir($dir)) !== false) {
        $local_file = $local_dir . '/' . $file;
        $remote_file = $remote_dir . '/' . $file;
        if (!is_dir($local_file)) {
            echo "Transferring {$local_file} to {$remote_file}\n";
            $scp_ret = ssh2_scp_send($con, $local_file, $remote_file, 0755);
            if (!$scp_ret) {
                fwrite(STDERR, "Failed to transfer {$local_file}.\n");
                exit(8);
            }
        } else {
            if ($file != "." && $file != "..") {
                sftp_walk($con, $sftp, $local_file, $remote_file);
            }
        }
    }
}
开发者ID:google-code-backups,项目名称:proveit-js,代码行数:21,代码来源:deploy.php


注:本文中的ssh2_scp_send函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。