Custom Command Example

The following example Command shows the configuration of a custom Command from the perspective of both EFT and a client. To follow the example exactly, you will need to download and install CuteFTP, which is available as a free 30-day trial and can be downloaded from https://www.globalscape.com/replacement-software. However, any client that supports custom commands or raw FTP commands will work.

Creating the Command

This Command copies EFT log files from the Logs folder to C:\Temp using the Windows xcopy command and CuteFTP's command-line functions.

To create a custom Command

  1. In the administration interface, connect to EFT and click the Server tab.

  2. On the Server tab, expand the Site node for the Site that you want to configure, and then click Commands.

  3. In the right pane, click New. The Custom Command Wizard appears.

  4. Follow the instructions in Creating a Command with the Custom Command Wizard to define a Command that uses xcopy.

Executing the Command

You can run the Command "on the fly," configure the Command in the FTP client (in this example, CuteFTP), or insert the Command in an Event Rule. Each of these methods is described below.

Using the Command "on the fly" in CuteFTP

  1. Start CuteFTP, and create a connection to EFT. (Refer to the CuteFTP help for details of how to connect to a server.)

  2. If not already displayed, open the Session Log pane. (On the main menu, click View > Show Panes >Individual Session Logs or press ALT+2.)

  3. 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.

  4. In the Command box, type site, the name of the Command as defined in EFT and any required parameters. For this example, type:
    site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbite" "C:\Temp"

  5. Click OK. The Command executes. In this example, each of the files in the \Usr\jbite folder was copied to the \Temp folder. If you selected the Return output to client check box when you defined the Command in EFT (step 8 above), the Session Log displays the results of the Command. For example:

COMMAND:> site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbite" "C:\Temp"

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\cftpsaiProperties.gif

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\EFTtaxonomy_filelist.xml

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\EFTtaxonomy_image001.png

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\inheritance.doc

220-220-C:\InetPub\EFTRoot\MySite\Usr\jbite\Message3.gif

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\RE Certificate Chaining.htm

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\Root Migration Scripts.htm

220-C:\InetPub\EFTRoot\MySite\Usr\jbite\Thumbs.db

220-8 File(s) copied

220-220-

220 Command completed with code 0.

Configuring the Command in CuteFTP

  1. Start CuteFTP and connect to EFT. (Refer to the CuteFTP help for details of how to connect to a server.)

  2. On the main menu, click Tools >Custom Commands >Edit Custom Commands. The Custom Commands dialog box appears.

  3. You must be connected to an FTP server in order for the Commands option to be available.

  4. Click New then type a name for the command. For this example, type xcopy.

  5. Click the command in the tree, and then click Edit or right-click the new command and click Properties. The Custom Command Properties dialog box appears.

  6. In the Label box, the name of the command appears.

  7. In the Command box, type:

  8. site xcopy "C:\InetPub\EFTRoot\MySite\Usr\jbite" "C:\Temp" /d

    Commands must start withsiteand then the command name you used in EFT, not the name you gave the command in CuteFTP. The/dparameter copies all new files in the specified folder.

  9. Optionally, specify any key or key combination for the Shortcut Key and any icon for the Toolbar Icon.

  10. Select the Place on the Custom Commands toolbar check box, and then click OK to close the Custom Commands Properties dialog box.

  11. 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 >Toolbars >Custom Commands Bar.)

  12. Start CuteFTP and connect to EFT.

  13. If it not already displayed, open the Session Log pane. (On the main menu, click View > Show Panes >Individual Session Logs or press ALT+2.)

  14. On the toolbar, click the Command icon that you just created.

  15. 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 Execute Command dialog box from within the Event Rule. See also Using an Event Rule to Execute a Command (Run a Process).

Possible Error Situations

  • If you repeat the hard coded parameters in both the client and EFT, 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 EFT, 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 EFT side.

  • You must give the FTP client user permission to run the Command on the Permissions tab on EFT; otherwise, 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 logged in to from a Local System account.

  • EFT can return an error if the client provides the wrong number of parameters or invalid parameters.

  • To limit security vulnerabilities to EFT, the EFT 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).