【问题标题】:scp ant copy from remote to local and use excludesscp ant 从远程复制到本地并使用排除
【发布时间】:2014-11-09 22:42:45
【问题描述】:

我正在尝试使用ant 中的scp 任务将远程服务中的文件复制到本地。问题是,我想排除某些扩展名为*.txt 的文件,所以我尝试使用excludes 标签。但这似乎不起作用。它会复制所有文件,包括扩展名为*.txt的文件

<scp file="username:pwd@remotemachine:/path/to/files/*" todir="copycontent" trust="true">
     <fileset dir="files" >
         <exclude name="**/*.txt"/>
     </fileset>
</scp>

【问题讨论】:

    标签: ant scp


    【解决方案1】:

    Ant SCP 任务对您的场景有一些限制:

    • “FileSet 仅适用于将文件从本地计算机复制到远程计算机。” (来自 Ant SCP 手册页)
    • SCP 元素本身不提供包含/排除模式的属性

    因此,从远程选择性复制到本地的选项是有限的。更灵活地从本地复制到远程(使用文件集)。

    除了排除*.txt之外,您还可以在一个或多个 scp 块中包含一个或多个文件模式。

    或者,如果本地系统是基于 unix 的,另一种选择是执行 rsync,如 this answer to a similar question 中所建议的那样。

    【讨论】:

    • 当我删除文件属性时,我收到一条错误消息'todir' and 'file' attributes must have syntax like the following: user:password@host:/path
    猜你喜欢
    • 2014-02-24
    • 2012-07-03
    • 2014-06-24
    • 2012-02-17
    • 2014-10-16
    • 2013-02-12
    • 2019-02-21
    • 2013-08-13
    • 2012-06-05
    相关资源
    最近更新 更多