The following example Command shows the configuration of a custom command from the perspective of both the EFT Server and client. To follow the example exactly, you will need to download and install CuteFTP Professional, which is available as a free 30-day trial and can be downloaded from http://www.globalscape.com/downloads. However, any client that supports custom commands or raw FTP commands will work.
This command copies the EFT Server log files from the EFT\Logs folder to C:\Temp using the Windows xcopy command and CuteFTP Pro's command-line functions.
To create a custom command
In EFT Administrator, connect to EFT Server and click the Server tab.
In the right pane, click New. A new set of tabs appear at the top of the pane named Command, Advanced, and Permissions.
On the Command tab, the Enable this command check box is selected by default.
In the Command Name box, type xcopy.
In the Description box, type Copy folder contents.
In the Executable box, type or browse for the path to the Windows xcopy command. By default, the path is C:\Windows\system32\xcopy.exe.
In the Output area:
Select the Redirect output to client check box, if you want the client to display the results of the command. (e.g., in CuteFTP, the output appears in the Log pane.)
Select the Redirect output to system log check box if you want to send the results of the command to the system log, EFT\cmdout.log.
In the Pass the following to the command box, you would provide the parameters required to execute the command. For this example, leave the box blank; you will provide the parameters when you run the Command in the client. (By leaving the command box blank, you can reuse this command for other copy tasks.)
The xcopy command can take multiple parameters, but you need at minimum the source and destination path. Select the Require parameters check box, then in the Command must have at least __ parameters box, type or select 2.
In the Invalid parameter count message field,
type the message that you want the connected client to receive if the
incorrect number of parameters is provided. You could also describe what
the proper syntax is so that the user knows what to provide. For this
example, type:
Invalid number of parameters. Correct syntax is: site xcopy "source"
"destination".
Select the Enable process timeout check box, and provide the number of seconds to wait for a failed process. For this example, in the Terminate Process if still running in __ seconds box, type or select 60.
In the Site users/groups box, double-click the users and/or groups who have permission to execute the command to move them to the Permit execution box.
Click Apply to save the command on EFT Server.
You can run the Command "on the fly," configure the Command in the FTP client (in this example, CuteFTP Professional), or insert the Command in an Event Rule.
Using the Command "on the fly" in CuteFTP Pro
Start CuteFTP Pro and connect to EFT Server.
If not already displayed, open the Session Log pane. (On the main menu, click View, point to Show Panes, then click Individual Session Logs, or press ALT+2.)
Right-click a blank area of the Session
Log, then click Input Raw FTP
Command, or press CTRL+SHIFT+I. The Input
FTP Command dialog box appears.
In the Command box,
type site,
the name of the Command as defined in EFT Server, and any required parameters.
For this example, type:
site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbug" "C:\Temp"
Click OK. The Command executes. In this example, each of the files in the \Usr\jbug folder was copied to the \Temp folder. If you selected the Return output to client check box when you defined the Command in EFT Server (step 8 above), the Session Log displays the results of the Command. For example:
COMMAND:> site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbug" "C:\Temp"
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\cftpsaiProperties.gif
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\EFTtaxonomy_filelist.xml
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\EFTtaxonomy_image001.png
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\inheritance.doc
220-220-C:\InetPub\EFTRoot\MySite\Usr\jbug\Message3.gif
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\RE Certificate Chaining.htm
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\Root Migration Scripts.htm
220-C:\InetPub\EFTRoot\MySite\Usr\jbug\Thumbs.db
220-8 File(s) copied
220-220-
220 Command completed with code 0.
Configuring the Command in CuteFTP Pro
Start CuteFTP Professional and connect to EFT Server. (See the CuteFTP Pro help for details of how to connect to the Server.)
On the main menu, click Tools, point to Custom Commands then click Edit Custom Commands. The Custom Commands dialog box appears.
You must be connected to an FTP server in order for the Commands option to be available. |
Click New then type a name for the command. For this example, type xcopy.
Click the command in the tree, then click Edit or right-click the new command and click Properties. The Custom Command Properties dialog box appears.
In the Label box, the name of the command appears.
In the Command box, type:
site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbug" "C:\Temp"
/d
Commands must start with site and then the command name you used in EFT Server, not the name you gave the command in CuteFTP. The /d parameter copies all new files in the specified folder. |
Optionally, specify any key or key combination for the Shortcut Key and any icon for the Toolbar Icon.
Select the Place on the Custom Commands toolbar check box, then click OK to close the Custom Commands Properties dialog box.
Click OK to close the Commands dialog box. Your custom command is now enabled and the icon, if specified, appears on the toolbar. (If the command is not displayed, click View, point to Toolbars, then click Custom Commands Bar.)
Start CuteFTP Pro and connect to EFT Server.
If it not already displayed, open the Session Log pane. (On the main menu, click View, point to Show Panes, then click Individual Session Logs, or press ALT+2.)
On the toolbar, click the Command icon that you just created.
Monitor the output in the Session
Log. You should receive various response messages indicating the
progress of the archive.
Executing the Command Automatically Using an Event Rule
If you want to copy the log file automatically every day, you can create a Scheduler (Timer) Event and insert the Execute command in folder Action. Using this method, you would have to define the parameters in the Custom Command dialog box from within the Event Rule.
Possible Error Situations
If you repeat the hard coded parameters in both the client and EFT Server, then the first parameter that the client sends will be used. For example, if SITE ZIP -c %at[archive name] %ff is configured in the client, and -c %1% %2% is configured in the Server, then the first parameter (-c) that the client sends will be used as %1% and the resulting string would be -c -c filename.ext. Therefore it is important to educate the FTP user on the proper syntax and supply most of the hard coded parameters on the Server side.
If you do not give the user permission to run the Command on the Permissions tab on EFT Server, they will receive a "Permission Denied" error.
Certain command line utilities that may show a Windows prompt or other dialog may not execute properly when called from the FTP Engine while it is running as a service. This is especially true when the service is being logged in from a Local System account.
EFT Server can return an error if the client provides the wrong number of parameters or invalid parameters.
To limit security vulnerabilities to the server, the server administrator should only allow limited access to commands that launch processes.
Always use caution when giving program access to your system32 directory (especially an FTP server). |