无法在 scp ssh 中复制带空格的文件名 [英] could not copy file name with space in scp ssh

查看:118
本文介绍了无法在 scp ssh 中复制带空格的文件名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法使用 ssh2_scp_recv() 函数复制文件名中有空格的文件.这是实际存储在服务器中的文件名 testfile-03_23_15 11 02 AM.csv.
我的代码在这里

I could not copy the file with spaces in file name using ssh2_scp_recv() function.This is the filename testfile-03_23_15 11 02 AM.csv which actually stored in server.
my code is here

if ($file == "testfile-03_23_15 11 02 AM.csv"){

    if(!ssh2_scp_recv($connection,$remoteDir .$file, $localDir . $file)){
        echo "Could not download: ", $remoteDir, $file, "\n";
    }
}

知道的请帮帮我.谢谢.

Please help me if you know. Thanks.

推荐答案

使用 phpseclib:

With phpseclib:

<?php
include 'phpseclib/Net/SSH2.php';
include 'phpseclib/Net/SCP.php';

$ssh = new Net_SSH2('www.domain.tld');
if (!$ssh->login('username', 'password')) {
    exit('bad login');
}
$scp = new Net_SCP($ssh);
$scp->get('file name with spaces');

这篇关于无法在 scp ssh 中复制带空格的文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆