簡體   English   中英

無法在scp ssh中復制帶有空格的文件名

[英]could not copy file name with space in scp ssh

我無法使用ssh2_scp_recv()函數復制文件名中帶有空格的文件。這是文件名testfile-03_23_15 11 02 AM.csv,它實際存儲在服務器中。
我的代碼在這里

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";
    }
}

如果您知道,請幫助我。 謝謝。

使用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');

試試這個:

 ssh2_scp_recv($connection,"\"".$remote_file_name."\"",$local_path."/".$remote_file_name); 

資料來源: php.net

它說: 試圖獲取名稱中帶有空格的遠程文件? 永遠不要忘記在遠程文件名中使用引號,但永遠不要在本地文件名中使用引號。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM