Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
202 views
in Technique[技术] by (71.8m points)

Ant, download fileset from remote machine

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.

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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...

Example

Configure SSH

Generate an SSH key (specify an empty passphrase):

ssh-keygen -f rsync

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

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

ssh -i rsync user@remote

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...