If you haven’t already got groovy installed, ensure it is (instructions for Fedora below):

Setup your working directory as follows:

log4j.properties has logging levels turned down, just so the line output is the file content from the FTP server.

ReadFileFromFtpServer.groovy is the main bulk of code which defines a camel route to connect to an ftp site with a username and password. Notice the @Grab annotations which pull in the required java libraries upon first attempting to run the script (these will download to ~/user/.groovy/grapes). It is also possible to trigger IntelliJ to download the dependencies for you: https://mrhaki.blogspot.com/2017/10/groovy-goodness-download-grab.html

Once you run the script with groovy ReadFileFromFtpServer.groovy you should see log output to console of any files on the ftp server. Note that the script will not consume the files due to the camel ftp option noop=true

References


codergists