Ant,从远程机器下载文件集 [英] Ant, download fileset from remote machine

查看:38
本文介绍了Ant,从远程机器下载文件集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,当通过 scp 任务从远程机器下载文件时,ant 不提供文件集"属性.它在从本地机器发送文件时工作,但在远程机器上启动时它不起作用.那是来自文档.所以在远程机器上,我在每个目录中有一些文件夹和文件加载.我想从每个文件夹中下载所有文件夹和一个指定的文件.下载所有文件然后删除不需要的文件不是解决方案,因为有数千个文件.

As I've readen ant doesn't provide 'fileset' attribute when downloading files from remote machine via scp task. It works when sending files from local machine, but It doesn't work when starting in remote machine. That's from documentation. So in remote machine I have some folders and load of files in every directory. I want to download all folders and one specified file from every of them. Downloading all files and then deleting unneeded files won't be solution beacuse there are thousands of files.

所以.如何从远程机器的指定目录下载所有文件夹(只在磁盘上创建没有内容的文件夹),然后从远程机器的每个目录下载一个指定的文件,并使用ant将其放到相应的文件夹中?

So. How to download all folders (only create the on disk without content) from specified directory in remote machine and then download one specified file from every directory in remote machine and put it to corresponding folder using ant?

推荐答案

由于您尚未指定,我将假定您的本地和远程系统是基于 Unix 的,因此支持 rsync 和 ssh.

Since you haven't specified I'll assume that your local and remote systems are unix based and therefore support rsync and ssh.

更具跨平台性的解决方案具有挑战性...

A more cross-platform solution is challenging...

生成 SSH 密钥(指定空密码):

Generate an SSH key (specify an empty passphrase):

ssh-keygen -f rsync

这会生成2个文件,分别对应私钥和公钥:

This will generate 2 files, corresponding to the private and public keys:

|-- rsync
`-- rsync.pub

在远程服务器上安装公钥

Install the public key on the remote server

ssh-copy-id -i rsync.pub user@remote

测试您现在可以执行无密码登录,使用 ssh 私钥进行身份验证:

Test that you can now perform a password-less login, using the ssh private key to authenticate:

ssh -i rsync user@remote

蚂蚁

下载"目标调用 rsync 在本地复制远程文件系统树.如果需要,可以另外指定 rsync 排除项(请参阅 rsync doco).

ANT

The "download" target invokes rsync to copy the remote file system tree locally. If required one can additionally specify rsync exclusions (see the rsync doco).

<project name="rsync" default="download">

    <target name="download">
        <exec executable="rsync">
            <arg line="-avz -e 'ssh -i rsync' user@remote:/path/to/data/ data"/>
        </exec>
    </target>

    <target name="clean">
        <delete dir="data"/>
    </target>

</project>

这篇关于Ant,从远程机器下载文件集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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