Skip to content
CA Process Automation - 4.2.2
Documentation powered by DocOps

Read Operating System Values into Dataset Variables

Last update November 20, 2017

CA Process Automation can read values that a shell process generates into dataset variables. Before a UNIX Script or Windows Script operator runs its associated script, it creates a folder to accept values that the script generates. The C2OSVD environment variable specifies the full path to the folder (for example, C:\TMP\_VS_559) that is created for the script operator. A script can then copy data to text files in the folder to pass the data back to CA Process Automation. Data that is passed back to CA Process Automation using the C2OSVD directory populates variables in the script operator dataset.

A script must save data to text files in the C2OSVD directory. After a script operator completes its script (but before it performs the post-execution actions), it determines whether the location to which C2OSVD points contains files. CA Process Automation then creates operator dataset variables according to the following rules:

  • The operator saves the contents of a file from the C2OSVD location to a string variable in the operator dataset. The string variable has the same name as the file.
  • A folder in the C2OSVD location generates an indexed variable in the operator dataset with the same name as the folder. The operator saves the contents of text files named in a numbered sequence located in the folder to corresponding elements in the indexed variable. The elements are numbered from 0 to as many elements as the highest numbered file in the folder. Missing files in the number sequence generate null elements in the indexed variable.
  • CA Process Automation requires a script to create files in the C2OSVD location with the same names as the variables you want to appear in the operator dataset. If the script creates text files with file extensions (such as .txt), CA Process Automation includes the extension in the variable name.

The following illustration shows the file-to-variable conversion when the working directory is set to C:\TMP. The operator appends \_VS_599 to the working directory path to create the C2OSVD value C:\TMP\_VS_599. The folder name (in this case _VS_599) is unique for every instance of any operator.

The illustration also shows two folders %C2OSVD%/HostList and %C2OSVD%\OSList that contain five files named 0, 1, 2, 3, and 4. The script writes a computer name to each numbered file in the HostList folder. The script writes an operating system name to each numbered file in the OSList folder. CA Process Automation creates two zero-based indexed variables after running the script, HostList and OSList. The application assigns the contents of the numbered files in the HostList and OSList folders to the corresponding elements of the indexed variables.

In the example, the Windows script uses the C2OSVD variable to create the file %C2OSVD%\NumRowsRead. CA Process Automation creates a corresponding variable (NumFilesRead) in the script operator dataset after it runs the script. The product then assigns the contents of the NumFilesRead file to the variable.

When a script operator finishes, it deletes the C2OSVD folder and its contents. The script operator post-execution code can access the operator dataset variables. The code typically copies the operator dataset variable values to local variables in the process dataset or to operator dataset variables in subsequent process operators.

A process can use UNIX script, VBScript, or PerlScript to read operating system variables into operator dataset variables. Each script reads lines from a text file that specifies a host name, a single space, and the operating system running on the host. For example:

JAMES Windows

INDUS Linux

NILE Windows

AMAZON UNIX

YANGTZE Solaris

GILA UNIX

The scripts save the host names to an indexed field named HostList and the operating system names to an indexed field named OSList.

The process incorporates the following steps:

  1. The UNIX or Windows module passes a text file name. The module gets the file name from a parameter on the appropriate Process tab of the script operator properties.
  2. The UNIX or Windows module creates and initializes the C2OSVD environment variable with a path to a unique folder.
    One instance of a script operator uses the folder that the C2OSVD environment variable specifies. The instance is not repeated or overwritten by any subsequent instance of that or any other script operator.
  3. The UNIX or Windows module creates the folder that the C2OSVD environment variable references.
  4. The script creates folders named HostList and OSList in the folder that the C2OSVD environment variable references.
  5. The script reads each line of the text file and takes the following actions:
    • The script writes the host names to sequentially numbered files in the %C2OSVD%\HostList folder.
    • The script writes the operating system names to sequentially numbered files in the %C2OSVD%\OSList folder.
    These files generate two indexed operator dataset variables HostList and OSList.
  6. The script writes the number of lines it read to the files to a file named %C2OSVD%/NumRowsRead.
    This file generates an operator dataset variable named NumRowsRead.

Contents:

Was this helpful?

Please log in to post comments.