简体   繁体   中英

could not copy file name with space in scp ssh

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.

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

Try this one:

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

Source: php.net

It says: Trying to get a remote file with spaces in its name? Never forget to use quotes in the remote filename, but never in the local one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM