【问题标题】:How to copy a directory from one host to another host?如何将目录从一台主机复制到另一台主机?
【发布时间】:2015-03-25 18:09:59
【问题描述】:

我想使用 SCP 将目录从一台主机复制到另一台主机 我尝试使用以下语法

my $src_path="/abc/xyz/123/";
my $BASE_PATH="/a/b/c/d/"; 
my $scpe = Net::SCP::Expect->new(host=> $host, user=>$username, password=>$password);
$scpe->scp -r($host.":".$src_path, $dst_path);

我得到的错误是没有这样的文件或目录。你能在这方面提供帮助吗?

【问题讨论】:

    标签: perl directory copy scp


    【解决方案1】:

    根据手册页中给出的示例,如果您已经将主机作为选项传递,则无需在调用中重复主机。

    来自http://search.cpan.org/~djberg/Net-SCP-Expect-0.12/Expect.pm:

    Example 2 - uses constructor, shorthand scp:
    
    my $scpe = Net::SCP::Expect->new(host=>'host', user=>'user', password=>'xxxx');
    
    $scpe->scp('file','/some/dir'); # 'file' copied to 'host' at '/some/dir'
    

    此外,这个“-r”是错字吗?如果要递归复制,需要在options hash中设置recursive => "yes"。

    【讨论】:

      猜你喜欢
      • 2017-04-30
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 1970-01-01
      相关资源
      最近更新 更多