FTP Command Action Example Flow Chart

FTP Command Action Example Flow Chart

The FTP Command Action allows fine grained control of what FTP commands Flux sends to an FTP, SFTP, or FTPS server. A list of commands is specified and executed sequentially, returning a list of each command's response from the server, if any.

The following example will instruct you on how to setup an FTP Command Action that will upload, download, and rename a file. The FTP Command Action always operates from a local machine to the specified FTP, SFTP, or FTPS host.

Viewing the Example Files

Your Flux installation includes a working, pre-constructed version of this example. To load the example file:

  1. Click the "Repository" tab.
  2. Choose the "Workflows" option.
  3. Click the "Upload" button.

In the dialog that appears, browse to <Flux Home>/examples/end_users/for_each_collection, and select the For Each Collection Element.ffc file.

When the workflow finishes uploading, select it from the grid and choose the "Edit" button to view the workflow in the Designer.

Navigating to the Designer

The Flux Designer will be used to create and execute the example flow chart. To use the Designer, browse to the Operations Console and select the "Designer" tab.


Creating Actions

When you visit the Designer, you'll se a blank workspace representing the new workflow. To create the example, we'll start by populating the workflow with a few actions.

To add an action to the workflow, select the appropriate category from 

When you return to the Designer, you will see a blank workspace representing the new flow chart. To create the example, you will need to populate the new flow chart with a few actions.

To add an action to the flow chart, you'll first need to select the action's category in the panel to the left of the workspace. Once you've selected the appropriate category, the action will appear in the panel – left-click the action and drag it onto the Designer workspace to add it to the workflow.

The following table contains the type, category, and quantity of each trigger and action we'll use in this example.

Action Type
FTP Command Action File


Console Action Core 1
For Each Collection Element Action Workflow 1

Once you've added the actions, your workspace will look like:

Setting up Flows

Using the image below as a guide, create flows between the actions. To create a flow:

  1. Click the connect button the Designer toolbar.

  2. Click and hold the left mouse button on the action you wish to draw the flow from.
  3. Drag your cursor to the action you wish to draw the flow to and release.

Editing Action Properties

FTP Command Action

Double-click the FTP Command Action to open its action properties panel. Find the commands property — this property will list the commands that the action will execute against the FTP server.

To add new commands, click the "+" icon and a new editor will appearing, allowing you to enter the command. Add the following commands to the action:

  • lcd C:\<flux installation directory>\examples\end_users\ftp_command
  • put test.txt
  • ls
  • rename test.txt file.txt
  • ls
  • lcd C:\<flux installation directory>\examples\end_users\ftp_command\receive
  • get file.txt

The "lcd" command will change your local working directory to the value you specify. Point it to the directory this example resides in. The "put" command will upload the test.txt file to the FTP server. The "ls" command will provide proof that the put command was successful by listing the test.txt file in the results. The "rename" command will rename the file to file.txt. The "ls" command, issued again, will show in the results that the file was in fact renamed to file.txt. The next "lcd" command changes the local directory in preperation to receive the new file. Finally, the "get" command downloads the newly renamed file back onto the local machine.

When you're done, the editor window will look something like:

Next we will need to set a host for the FTP Command Action to connect to and issue the specified commands. Any FTP, SFTP, or FTPS server you have available that is accessible from the machine you are running Flux on will work for this action. If you do not have a server available you can download a number of different FTP servers from the internet. There are also many sites that allow you to register and use their remote file transfer servers.

Once you have a reachable file transfer server with valid credentials, go into the Flux designer and edit the "Host" action property of the FTP Command Action. Select the type of hose you are connecting to using the top radio buttons of the "Host" panel. Fill in the "Host name", "User Name", and "Password" fields with the appropriate information. You may also modify the "Port" field if the server you are connecting to is not listneing on a default port. The figure below shows the "Host" panel. 
Editing the Host Property

For Each Collection Element Action

The For Each Collection Element Action will take the returned result from the FTP Command Action and iterate through each response. We need to set the "Loop Index" action property of the For Each Collection Element Action to "response". Do this by clicking the For Each Collection Element Action in the canvas and editing the "Loop Index" property that appears in the "Action Properties" tab.

Console Action

Edit the Console Action "Message" action property to read ${response}. This finds the For Each Collection Element Action's value within that loop iteration and uses it as the Console Action's message.

Editing Flows

Next we need to add a runtime data map onto the flow out of the FTP Command Action. You can do this by right clicking the flow out of the FTP Command Action and clicking the "Edit runtime data map" option.

Flow Options

This will bring up the runtime data map editor. Add a new entry into the runtime data map by clicking the button with the green addition sign. Make sure the source type is from the "Flow Context" and the target type is from the "Action". Next edit the "Name" field of the source data map to read "result.result" and the target "Name" field to use the "Collection" property. The figure below illustrates the runtime data map.

Ftp Command Action Flow's Runtime Data map

With that change the flow chart is complete and ready to export to the engine.

Creating a Flux Engine

Run the start-unsecured-flux-enginescript from the Flux installation directory to start an unsecured Flux engine.

Next, return to the Flux Designer and move your cursor over the “Flux Engines” tab located to the left of the workspace.

Click the button at the top of the “Flux Engines” tab and the window shown in Figure 16 below will appear.

The Engine Setup Wizard

Click on the “Advanced” tab at the top of the window, then click the "OK" button.

You will return to the Designer workspace. Look at the “Flux Engines” tab again. The engine you just started should look like Figure 17, shown below.

Running Engine Indicator

Running the Flow Chart

Next, export your flow chart to the engine. This can be accomplished by right-clicking anywhere on the Designer workspace and selecting the “Export to remote job scheduler engine” option.

Exporting to the Engine from the Designer Workspace

Click the "OK" button in the window that appears.

Exporting the Flow Chart to the Engine

A confirmation window will appear if the job was successfully exported. Click the "OK" button on the confirmation message. If there is an error message, look over this example carefully, and correct any mistakes made.

Export Was Successful

If you look at your engine's console, you should see the listing from your server showing the uploaded, then renamed file on two seperate lines (along with any other files present in the user's home directory when the example was run).

Once this example is completed, shut down the Flux engine by running the shut-down-unsecured-flux-enginescript from the Flux installation directory.

Was this article helpful?
0 out of 0 found this helpful



Please sign in to leave a comment.