Using Variables in FTP Jobs

This page explains how to specify and use variables in FTP Jobs.

Note:

This example assumes that you have at least basic knowledge of Automic Automation features. For more information, see PromptSets (PRPT) and FOREACH Workflows.

We define an FTP Job that has a variable that specifies an FTP host. We use this variable in FTP commands. This is what will happen:

  • If the job is executed individually, the value of the variable is set by a prompt in a PromptSet object, where a VARA object is assigned as the Prompt's data reference. This allows you to select a host from a dynamic list.

  • If the job is executed within a ForEach Workflow, the value of the variable is set by the ForEach Workflow properties, where a VARA object is assigned as the source for the variable's value. When the Workflow runs, it spawns an instance of the FTP Job for every host returned by the VARA object.

An FTP Agent Job named JOBS.FTPAGENT.GET_CARD_TRANSACTIONS_SELECT_REMOTE_HOST is shown below. The variable &CONNECTION# is entered as the From host. This means that when the Job is executed, the value for the From host will be determined by the value of the &CONNECTION# variable.

12345678901234567890

The Job includes the three commands shown in detail the three images below. Each command also uses the &CONNECTION# variable:

The image shows a "Create directory" task that uses the variable \&CONNECTION\# for both connection and path. This variable, also used for the host in FTP jobs, gets its value from a PromptSet or ForEach Workflow. The task is set to "Abort the job on command failure."

The image displays an FTP Agent Job configured for binary, stream-mode transfer. Both source and destination hosts use the &CONNECTION# variable, defined in a PromptSet or ForEach Workflow, to dynamically select a host. The source path is /home/CardTransactions/*, and the destination is /home/CardTransactions/&CONNECTION#/ on the Agent file system. Transferred files are erased from the source.

The image shows settings for renaming a file in an Agent file system. The file path /home/CardTransactions//&CONNECTION#/ is being renamed to /home/CardTransactions//&CONNECTION#_&$PHYS_TIME_HHMMSS#. The "Abort the job on command failure" option is selected. The variable &CONNECTION# specifies an FTP host, and its value is determined by a PromptSet object. The &$PHYS_TIME_HHMMSS# variable likely represents the physical time with hours, minutes, and seconds.

The &CONNECTION# variable is set each time the JOBS.FTPAGENT.GET_CARD_TRANSACTIONS_SELECT_REMOTE_HOST Job is executed by a prompt defined in a PromptSet object named PRPT.CONNECTION, which is assigned to the Job as shown below:

"The AWI displays prompt set management within automation/job settings. The left menu shows "Prompt Sets" selected. The "Prompt Sets" table lists sets by "Name" and "Title," highlighting "PRPT.CONNECTION." Under "Prompts," a "Select a Connection" dropdown shows "STORE12." Buttons allow users to "Add," "Edit," "Remove," "Move Up," and "Move Down" PromptSets.

The PromptSet definition for PRPT.CONNECTION is shown below. Notice that the VARA object VARA.SQLI.CONNECTION_NAME is the data reference for PRPT.CONNECTION's only prompt.

The image shows the PromptSet Designer where the setting for the prompt "Select a Connection" uses VARA.SQLI.CONNECTION_NAME as the data reference and &CONNECTION as the variable name. STORE12 is the manual default selection. This configuration dynamically selects an FTP host from a VARA object-generated list (e.g., STORE<number>) via an SQL statement for FTP Jobs.

The VARA definition for VARA.SQLI.CONNECTION_NAME is shown below. It includes the following SQL statement.

select oh_name from oh where oh_otype='CONN' and oh_name like '%STORE%' and oh_name not like '%OLD%'

This SQL statement returns a list of hosts based on the naming convention STORE<number>.

The image shows variable settings for an SQL-internal type, including a SQL Server statement similar to VARA.SQLI.CONNECTION_NAME from "Using Variables in FTP Jobs." This statement selects oh_name from the oh table where oh_otype is 'CONN' and oh_name is like '%ST...%', returning a list of host names, specifically those following the "STORE" naming convention and excluding "OLD." The image also previews results like STORE01, STORE02, and STORE03.

JOBS.FTPAGENT.GET_CARD_TRANSACTIONS_SELECT_REMOTE_HOST is included as the only task in the JOBP.FOREACH.REMOTE_HOST For Each Workflow below.

In the For Each details, VARA.SQLI.CONNECTION_NAME is specified as the variable in the Name field. And &CONNECTION# is set as the variable to publish values to.

When the JOBP.FOREACH.REMOTE_HOST Workflow is executed, it spawns an instance of the JOBS.FTPAGENT.GET_CARD_TRANSACTIONS_SELECT_REMOTE_HOST FTP Job for every host returned by the VARA.SQLI.CONNECTION_NAME VARA object.

The image shows a ForEach Workflow. The Iteration Source is a Variable object named VARA.SQLI.CONNECTION_NAME. The value is published as &CONNECTION#. When the workflow runs, it spawns an instance of the FTP Job for every host returned by the VARA object.

See also: