Skip to content

Instantly share code, notes, and snippets.

@ran488
Created August 9, 2011 20:03
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ran488/1135043 to your computer and use it in GitHub Desktop.
Save ran488/1135043 to your computer and use it in GitHub Desktop.
Simple FTP file retrieval sample (Groovy)
@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.");
@littleFree
Copy link

where is FTPClient() from ? the third ftp library?

@TheHairyGun
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment