Created
August 9, 2011 20:03
-
-
Save ran488/1135043 to your computer and use it in GitHub Desktop.
Simple FTP file retrieval sample (Groovy)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Grab(group='commons-net', module='commons-net', version='2.0') | |
import org.apache.commons.net.ftp.FTPClient | |
println("About to connect...."); | |
new FTPClient().with { | |
connect "some-server.some-domain.com" | |
enterLocalPassiveMode() | |
login "your-username", "your-password" | |
changeWorkingDirectory "/var/appl/some/remote/dir/" | |
def incomingFile = new File("some-file-to-retrieve.log") | |
incomingFile.withOutputStream { ostream -> retrieveFile "some-file-to-retrieve.log", ostream } | |
disconnect() | |
} | |
println(" ...Done."); |
It's just an implementation of the Apache Commons FTP library.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
where is FTPClient() from ? the third ftp library?