The following example command shows the configuration of a custom command from the perspective of both the FTP Server and client. CuteFTP Professional will be the client used in this example, although any client that supports custom commands or raw FTP commands will work.
This command will compress an archive from the command line using CuteZIP's command line functions. Before attempting the following example, you will need to download and install CuteFTP Professional and CuteZIP. Both are available as a free 30-day trial and can be downloaded from www.globalscape.com.
Start the CuteFTP Server Administrator Interface and connect to the Server.
At the bottom of the left pane, click the Server tab.
In the left window, expand a Server Group, a Server and a Site.
Select Commands.
In the right pane, click New. A new set of tabs will appear named Commands, Advanced and Permissions.
On the Commands tab, select the Enable this command check box.
In the Command field, enter the name ZIP.
In the Description field, enter Compress selected files.
In the Executable field, browse until you locate C:\program files\globalscape\cutezip\cutezip.exe.
Note: You must have already installed CuteZIP on your computer.
Beneath Output, select the Redirect output to client check box.
Select the Redirect output to system log check box.
Click the Advanced tab.
In the Pass the following to the command box, enter -c %1% %2%.
Select the Require parameters check box.
Select 2 in the Command must have at least __ parameters drop down box.
In the Invalid Parameter Count Message field, enter Invalid Command! Usage Site ZIP [destination] [source].
Select the Enable process timeout check box.
Select 60 in the Terminate Process if still running in __ seconds drop down box.
Click the Permissions tab.
Add Users or Groups that will have permission to execute the command.
You will need to have CuteFTP Professional installed on your computer before you complete this section.
Start CuteFTP Professional and connect to CuteFTP Server.
From the menu bar, click Commands > Custom Commands > Edit Custom Commands.
Note: You must be connected to an FTP server in order for the Commands option to be available on CuteFTP Pro's menu bar.
Click the New Command icon and give your command a name.
Right-click the new command and select Properties.
For the Label, enter ZIP Files on the Server.
For the Command, enter SITE ZIP %at[archive name] %ff .
Note: Commands must start with SITE and then the command name you used in Server.
Choose any key or key combination for the Shortcut Key.
Choose any icon for the Toolbar Icon.
Select the Place on the Custom Commands toolbar check box.
Click OK in the Custom Commands Properties dialog box.
Click OK to exit the Commands dialog box. Your custom command should now be enabled.
Perform the following steps to test your custom command:
Start CuteFTP Pro and connect to the CuteFTP Server.
From the menu bar choose Commands > Custom Commands > New Command Name.
Monitor the output to the client log. You should receive various 220 response messages indicating the progress of the archive.
If you repeat the hard coded parameters in both the client and server, such as SITE ZIP -c %at[archive name] %ff is used in the client, and -c %1% %2% in the sever, then the first parameter (-c) that the client sends will be used as %1%. So the resulting string would be: -c -c filename.ext. Therefore it is important to educate the user on the proper syntax and supply most of the hard coded parameters on the server side.
If you don't add the user to the Permissions table in the Permissions tab on the server, then 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.
The server may return an error if the client provides the wrong number of parameters or invalid parameters. In order to limit security vulnerabilities to the server, the server administrator should only allow limited access to commands that launch processes.