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.

Getting Started

Open the Flux Designer by executing the flux-designer script from the Flux installation directory. The Designer will be used to create and execute the example flow chart.

       
Once the Designer is running, select "Open Project" from the "File" menu. Browse to the directory /examples/end_users/ftp_commandand select the file fluxproject.fpr, then click the "Open" button to load the example project.

To view and run this example from the pre-made flow chart, double-click the "Ftp Command" flow chart in the "Project View" panel to the left of the Designer workspace. Look over the example flow chart. If you require an in-depth explanation of any element in the example, read through the steps below. Otherwise, proceed to the section "Running the Flow Chart" to view the example in action.

If you would rather create the flow chart yourself, select "New" from the "File" menu. Select "New Flow Chart" in the window that appears, then click the "OK" button.

       
Creating a New Flow Chart in the Flux Designer

Name the new flow chart and click the "OK" button.

Creating Actions

After you have created a flow chart, the Designer will open with a blank workspace. To create this example, you will need to populate the new flow chart with the required actions. The "Actions & Triggers" panel, located to the left of the Designer workspace, contains all of the actions necessary for this example. The bulleted list below contains the name of each action, the quantity required, and the tab each is located under in the "Actions & Triggers" panel. Drag the necessary quantity of each action onto the Designer workspace.

“Actions” Tab:

  • Action: "Ftp Command Action"
    • Category: "File"
    • Quantity: 1
  • Action: "Console Action"
    • Category: "Core"
    • Quantity: 1
      When you have dragged the necessary quantity of each action to the Designer workspace, arrange them according to the figure below.

       
Actions and Triggers Panel

When you have dragged the necessary quantity of each action to the Designer workspace, arrange them according to the figure below.

       
Actions Layout

Setting up Flows

Using Figure 7 as a guide, create flows between the actions. To create a flow:

  1. Click the blank white space within your drawing canvas.
  2. Click and hold 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.

       
Flow Layout

Editing Action Properties

FTP Command Action

Next, make sure the “Ftp Command Action” is selected so that you can see its action properties in the “Action Properties” panel on the right of your screen. Highlight the "Commands" action property by clicking it. Edit the property by clicking the ellipsis button that appears to the right of the property box. Add the following commands into the commands list:

  • 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. The following figure shows the commands inserted into the action's Command property. 
Editing the Commands Property

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

Comments

0 comments

Please sign in to leave a comment.