Skip to content

Instantly share code, notes, and snippets.

@crazy4groovy
Forked from ran488/simple-ftp-sample.groovy
Created January 20, 2014 19:31
Show Gist options
  • Save crazy4groovy/8527407 to your computer and use it in GitHub Desktop.
Save crazy4groovy/8527407 to your computer and use it in GitHub Desktop.
@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.");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment