本文整理汇总了PHP中ssh2_scp_recv函数的典型用法代码示例。如果您正苦于以下问题:PHP ssh2_scp_recv函数的具体用法?PHP ssh2_scp_recv怎么用?PHP ssh2_scp_recv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ssh2_scp_recv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: receive
/**
*
* @param string $remoteFileName
* @param string $localFilename
* @throws \Exception
*/
public function receive($remoteFileName, $localFilename)
{
if (empty($this->session)) {
throw new \Exception("Veuillez vous connecter au serveur avant de demander un fichier");
}
ssh2_scp_recv($this->session, $remoteFileName, $localFilename);
}
示例2: download_file
function download_file($file_path, $new_file_path)
{
if ($this->sftp_connection) {
return @ssh2_scp_recv($this->ssh2_connection, $file_path, $new_file_path);
}
return false;
}
示例3: scp_recv
public function scp_recv($remote_path, $local_path)
{
if (!isset($this->socket) || !is_resource($this->socket)) {
$this->connect();
}
try {
ssh2_scp_recv($this->socket, $remote_path, $local_path);
$this->disconnect();
} catch (Exception $e) {
// close the connection after scp command
$this->error_handler($e);
}
}
示例4: download
public function download($remoteFilename, $localFilename, $overwrite = false)
{
if (!$overwrite and file_exists($localFilename)) {
throw new ConnectionException('File exists and overwrite flag is not set');
}
if (!is_writable(dirname($localFilename))) {
throw new ConnectionException('Local directory is not writable');
}
if (!is_resource($this->sftpResource)) {
throw new ConnectionException('Connection is not open');
}
$scpResult = @ssh2_scp_recv($this->sshResource, $this->getRemotePath($remoteFilename), $localFilename);
if ($scpResult) {
return $this;
} else {
throw new ConnectionException('Unable to download file');
}
}
示例5: getFile
public function getFile($remoteFile, $localFile)
{
$this->logAction("Receiving file {$remoteFile} as {$localFile}");
if (ssh2_scp_recv($this->conn, $remoteFile, $localFile)) {
return true;
}
$this->logAction("Receiving file {$remoteFile} as {$localFile} failed");
throw new Exception("Unable to get file to {$remoteFile}");
}
示例6: scpRecv
/**
* Facade for file_put_contents over ssh2.
*
* @param resource $session The sftp resource to use.
* @param string $remote_file The remote path to get from.
* @param string $local_file The local file to write to.
*
* @return boolean True on success.
*/
public function scpRecv($session, $remote_file, $local_file)
{
return ssh2_scp_recv($session, $remote_file, $local_file);
}
示例7: get
public function get($remote, $local)
{
return ssh2_scp_recv($this->conn_, $remote, $local);
}
示例8: get_contents
function get_contents($file, $type = '', $resumepos = 0)
{
$this->debug("get_contents();");
$tempfile = wp_tempnam($file);
if (!$tempfile) {
return false;
}
if (!ssh2_scp_recv($this->link, $file, $tempfile)) {
return false;
}
$contents = file_get_contents($tempfile);
unlink($tempfile);
return $contents;
}
示例9: dol_syslog
if ($connection) {
if (!@ssh2_auth_password($connection, $login, $password)) {
dol_syslog("Could not authenticate with username " . $login . " . and password " . $password, LOG_ERR);
exit(-5);
} else {
//$stream = ssh2_exec($connection, '/usr/bin/php -i');
/*
print "Generate dump ".$filesys1.'.bz2'."\n";
$stream = ssh2_exec($connection, "mysqldump -u debian-sys-maint -p4k9Blxl2snq4FHXY -h 127.0.0.1 --single-transaction -K --tables -c -e --hex-blob --default-character-set=utf8 saasplex | bzip2 -1 > ".$filesys1.'.bz2');
stream_set_blocking($stream, true);
// The command may not finish properly if the stream is not read to end
$output = stream_get_contents($stream);
*/
$sftp = ssh2_sftp($connection);
print 'Get file ' . $sourcefile . ' into ' . $targetdir . $targetfile . "\n";
ssh2_scp_recv($connection, $sourcefile, $targetdir . $targetfile);
$fullcommand = "cat " . $targetdir . $targetfile . " | mysql -h" . $databaseserver . " -u" . $loginbase . " -p" . $passwordbase . " -D " . $database;
if (preg_match('/\\.bz2$/', $targetfile)) {
$fullcommand = "bzip2 -c -d " . $targetdir . $targetfile . " | mysql -h" . $databaseserver . " -u" . $loginbase . " -p" . $passwordbase . " -D " . $database;
}
if (preg_match('/\\.gz$/', $targetfile)) {
$fullcommand = "gzip -d " . $targetdir . $targetfile . " | mysql -h" . $databaseserver . " -u" . $loginbase . " -p" . $passwordbase . " -D " . $database;
}
print "Load dump with " . $fullcommand . "\n";
$output = array();
$return_var = 0;
print strftime("%Y%m%d-%H%M%S") . ' ' . $fullcommand . "\n";
exec($fullcommand, $output, $return_var);
foreach ($output as $line) {
print $line . "\n";
}
示例10: ssh2_connect
///////////////////////////////////
// Abrindo conexão novamente ssh //
$connect_ssh = ssh2_connect($_SESSION['ipserver'], 22);
if (ssh2_auth_password($connect_ssh, $_SESSION['login'], $_SESSION['password'])) {
echo "Conectado..." . "<br>";
}
//////////////////////////////////////
// Iniciando Deletagem das linha... //
$remote_file = "/etc/bind/named.conf.local";
//way arq a ser copiado
$local_file = "/tmp/named.conf.local.cpy";
//way arq copiado
$local_file_modif = "/tmp/named.conf.local.cpy.alt";
//wau arq alterado
// Copiando arquivo do server remote e testando se houver falha...returna false
if (!ssh2_scp_recv($connect_ssh, $remote_file, $local_file)) {
return false;
}
//Abrir file
$file_original = fopen($local_file, 'r');
//abri arq para leitura
$file_alterado = fopen($local_file_modif, 'w');
//cria um arq zerado
// Var. para avisar se deve copiar ou não linha atual do laço
$delete_line = false;
//var. para ir increment. ate chegar a 4, q deve ser quando deve parar de exlucir as linhas
// o "excluir na verdade eh não copiar a linha para o arquivo $local_file_modif
$cont = 0;
for ($i = 0;; $i++) {
$linha = fgets($file_original);
if (strstr($linha, $_GET['domain']) || $delete_line) {
示例11: get
/**
* Copy a remote file on local filesystem.
*
* @param string $local_file
* @param string $remote_file
* @param boolean $overwrite
*
* @return boolean Returns TRUE on success or FALSE on error
*
* @throws \BackBee\Util\Transport\Exception\TransportException Occures if SSH connection is invalid
*/
public function get($local_file, $remote_file, $overwrite = false)
{
if (null === $this->_sftp_resource || null === $this->_ssh_resource) {
throw new TransportException(sprintf('None SSH connection available.'));
}
$remote_file = $this->_getAbsoluteRemotePath($remote_file);
if (true === $overwrite || false === file_exists($local_file)) {
if (false === @ssh2_sftp_stat($this->_sftp_resource, $remote_file)) {
return $this->_trigger_error(sprintf('Could not open remote file: %s.', $remote_file));
}
if (false === @ssh2_scp_recv($this->_ssh_resource, $remote_file, $local_file)) {
return $this->_trigger_error(sprintf('Could not send data from file %s to file %s.', $remote_file, $local_file));
}
return true;
}
return $this->_trigger_error(sprintf('Local file already exists: %s.', $local_file));
}
示例12: download
/**
* @param $remoteFile
* @param $localFile
* @return bool
*/
public function download($remoteFile, $localFile)
{
return ssh2_scp_recv($this->connection->getConnection(), $remoteFile, $localFile);
}
示例13: downloadFile_Single_Stream
public function downloadFile_Single_Stream($local_file, $remote_file)
{
$connection_data = $this->getSSH2Connection();
if (!$connection_data->connected) {
//---------------------------------------------------------------------------------------------------------------
if (PHP_SSH2MST_DEBUG) {
echo "\n\n_____________FILE TRANSFER FAILED___________\n";
}
//---------------------------------------------------------------------------------------------------------------
$this->parent->transfer_status = PHP_SSH2MST_TRANSFER_STATUS_FAILED;
return 0;
}
$res = ssh2_scp_recv($connection_data->connection_handle, $remote_file, $local_file);
//release the connection - we dont need it anymore
$this->ReleaseConnection($connection_data);
return $res;
}
示例14: scpRecv
public function scpRecv($remote_file, $local_file)
{
if (!($inifile = ssh2_scp_recv($this->con, $remote_file, $local_file))) {
throw new \Exception('Unable to retrieve file');
}
}
示例15: getFile
/**
* Fetch a file from the remote server via SCP.
*
* @param string $remote_file
* @param string $local_file
*
* @return bool true if successful
*/
public function getFile($remote_file, $local_file)
{
return ssh2_scp_recv($this->session, $remote_file, $local_file);
}