edtFTPj/PRO includes a powerful
scripting engine that allows users to list FTP commands in a text file,
and then execute all the commands sequentially. The script can be be
run via a batch
file (or Unix shell script), or the ScriptEngine
class can be used within an application to run a script.
The script engine supports the FTP,
FTPS (both implicit and explicit) and SFTP protocols. For FTPS, both client and server validation is
A sample script is shown
# Sample FTP script using FTP
# then changing to FTPS
# client and server validation for FTPS
# logging off = 0, highest level = 5
# connect to the server
# optional remotehost and port supplied
# override the params set earlier
open edtmobile 21
# change to secure mode
# force binary mode transfers
# put the local file test.jar to the server as mytest.jar
put test.jar mytest.jar
# rename it
rename mytest.jar test2.jar
# and get it back as test3.jar in the local working directory
get test2.jar test3.jar
# delete all *.jar files in the current directory on
# the server
To run the above script, assuming
it is saved in a file called
simply supply it as the first argument to the ScriptEngine
java -classpath %CP%
(where %CP% contains edtftpjpro.jar and license.jar).
Alternatively, a comprehensive set of command line parameters can be used as described below:
[-h] [-c configfile] [-f scriptfile] [-u user] [-p password] [-v]
-f scriptfile : script to execute.
-c configfile : config script to execute before main scriptfile.
-h : display this help
-u user : set the user name (optional)
-p password : set the user password (optional)
-v : print version details
java -classpath %CP%
com.enterprisedt.net.ftp.script.ScriptEngine -c config.txt -f script.txt
In this example, a configuration file is supplied in addition to the script file to run. The settings in
the configuration file are loaded before the script file is executed, so the file can be used for common settings.
If the runscript.bat (or runscript on Unix)
batch script is used:
runscript -c config.txt -f script.txt
If the ScriptEngine is used directly from code to run
scripts via the executeScript() methods, the ScriptResult object
that is returned can be examined for various statistics collected about the script execution.
Most commands are fairly self explanatory.
The set command
is used to set various parameters that are used during the session,
such as username, password, timeout and so on. Many of these parameters
are optional (e.g. port, timeout). The
most important parameter is the
The local working directory is by
default the standard Java working
directory for the application, but the set localdir
command can be used to set a different local working directory. All
uploads and downloads that do not specify a full path will use the set
The scripting commands are
described in the command reference.