Execute Program/Script (any) - Teradata Warehouse Miner

Teradata Warehouse Miner User Guide - Volume 2ADS Generation

Product
Teradata Warehouse Miner
Release Number
5.4.4
Published
July 2017
Language
English (United States)
Last Update
2018-05-03
dita:mapPath
fcf1492702067123.ditamap
dita:ditavalPath
ft:empty
dita:id
B035-2301
Product Category
Software

A program or script may be executed using an Execute Program/Script Run Unit, which executes the program as if from a DOS standard command line, with optional command line arguments, environment variables, working directory and redirected standard input, output and error messages. A good example of such a program is the Teradata BTEQ (Basic Teradata Query) utility, which executes commands (i.e., a script) taken from Standard Input.

An Execute Program/Script Run Unit utilizes substitution parameters in a manner similar to a SQL Text with Arguments SQL element, replacing <P1> with the SQL generated for the first expression in the Substitution Parameters folder, <P2> for the second, and so forth. Substitution parameters may be used in command line arguments, script commands (i.e., standard input), environment variables and the working directory. Additionally, substitution is provided in these same fields for the logon data source name and project attachment file names and paths. Specifically, the symbols <DSN> are replaced by the current logon data source name, and the name of a project attachment enclosed in <> is replaced by the fully qualified project attachment file name in temporary storage.
The use of placeholders for project attachment file names is not supported in silent batch processing mode. Also, if the data source name contains spaces, the user should most likely enclose the placeholder in double quotes like this: “<DSN>”.

When dragging an Execute Program/Script element onto a Run Unit, the following tree element is created.

Variable Creation > Input > Variables: SQL Elements pane - Run Units > Execute Program/Script

At the same time, a Properties dialog is displayed so that a Program/Script can be specified.

Variable Creation > Input > Variables: SQL Elements pane - Run Units > Execute Program/Script Properties

  • Program File — Name of the program file to be executed, for example “bteq.exe”.
  • Full Path — Program name and full directory path, for example, “C:\Program Files (x86)\Teradata\Client\15.00\bin\bteq.exe”. This can be obtained using the Browse button, and in some cases the Registry button, as described below. Note that this field is not required if the Program File is located in a directory contained in the user’s Path environment variable.
  • Working Directory — When a valid directory or folder is entered here (such as C:\Temp), the Program File executes with this as the default directory for any files it may reference.
  • Arguments — Command line arguments, if any, should be specified here.
  • Run in detached process (don’t wait) — Checking this box causes the Program File to be executed independently as a separate process and the current Run Unit not to wait for the submitted process to complete. When this box is checked, the Std In, Std Out and Std Error tabs are not displayed and are ignored by the submitted process.
  • Registry — Searches the client Registry for the Program File entered above. In order for the search to be successful, an entry for the Program File must exist in the registry area “Software\Microsoft\Windows\CurrentVersion\App Paths\”, which may not be true.
  • Browse (Full Path) — Opens the standard dialog for locating a file. Once located, the full file path is placed in the Full Path text box.
  • Browse (Working Directory) — Opens the standard dialog for locating a file. Once located, the path is placed in the Working Directory text box.
  • Env Vars… — Opens the Environment Variables dialog to either set new values for existing environment variables or add new environment variables. Note that values and variables entered here remain active only during the execution of the Program/Script.
    Environment Variables dialog

    Use this dialog to Enter Name/Value pairs for existing or new environment variables as desired. The following rules apply to the entries on this dialog.
    • An Environment Variable must have a name
    • The name of an Environment Variable must not contain an equal sign (“=”).
    • The same name may not be entered more than once
    • Environment Variable names are not case sensitive
    • A new or existing Environment Variable may receive an empty string as its value
  • Std In tab
    • Read Script From File — If this option is selected, program/script commands are taken from a file.
    • Browse — The Browse button can be used to locate the script command file above.
    • Edit — The Edit button can be used to alter the script command file specified, or to extract the script and place it in the Enter Script as Text field for additional changes.
    • Enter Script as Text — Script commands can be entered or copied here as an alternative to reading the script from a file. This may be useful for script development and for storing the script with the analysis.
  • Std Out tab
    • Save To File — If this option is selected, the program’s Standard Output is written to a file with the specified full name and path.
    • Append — If checked, this option saves Standard Output to the end of an existing file, retaining the file’s previous content.
    • Browse — The Browse button can be used to locate a file for Standard Output.
    • Output — This read-only text area displays the Standard Output data from executing the program/script. This data is saved with the analysis.
  • Std Error tab
    • Save To File — If this option is selected, Standard Error data is written to a file with this full name and path.
    • Append — If checked, this option saves Standard Error data to the end of a file, retaining the file’s previous content.
    • Browse — The Browse button can be used to locate the path of the file that Standard Error is being written to.
    • Error Messages — This read-only text area displays the Standard Error data from executing the program/script. This data is saved with the analysis.
  • Execution group box area
    • Run Unit Name — Name of the Run Unit whose properties are displayed.
    • Message — This indicates a status of Complete or Canceled or an error message, if any.
    • Save and Run button — Saves the contents of the Properties dialog and runs the program. This is not enabled if the analysis or an individual Run Unit is already executing. When execution completes, status information is returned along with Standard Output and Standard Error data. If it is necessary to cancel the execution of the script, use the Stop button on the application tool bar.
  • Status area
    • Start — Start time of the last run.
    • Stop — Stop time of the last run.
    • Exit Code — Exit code of the run: 0 for success or another value for error.
    • Reset Results — Clears the Status and Execution fields, along with Standard Out and Standard Error data.

In the following example, the first picture shows that an Execute Program/Script Run Unit has been dropped or selected just underneath the Run Unit1 node, and a substitution parameter containing the name of the table to process (twm_customer) has been dragged or selected into the Substitution Parameters folder.

Variable Creation > Input > Variables: SQL Elements pane - Run Units > Execute Program/Script (Substitution Parameters folder)

The following Properties panel is displayed when the Properties button is selected while this Execute Program/Script node is highlighted. Notice that the substitution parameter <P1> is present in the script. It will be replaced during execution by the value twm_customer.

Variable Creation > Input > Variables: SQL Elements pane - Run Units > Execute Program/Script Properties (Std In)

After clicking Save and Run at the bottom of the panel, the program output is automatically displayed as in the figure below. If an error occurs, the Std Error tab will be displayed.

Variable Creation > Input > Variables: SQL Elements pane - Run Units > Execute Program/Script Properties (Std Out)