Parse command output

As part of creating or modifying a pattern, you can use the Parse command output operation to extract information from the command output and to save the operation result in a variable. You can also save the whole of command output as a variable.

Before you begin

Navigate to the relevant pattern step:

  1. On the pattern form:
    • Select the relevant identification section for Discovery.

      Or

    • Select the relevant identification or connection section for Service Mapping.
  2. Select the relevant pattern step or click to add a step.

Role required: pd_admin

Basic knowledge of programming is desirable.

Procedure

  1. Select Parse command output from the Operation list.
  2. Specify the command in Set Command Details.

    You can concatenate multiple commands.

    Important: Avoid entering a specific path to a location or file because it can be different on different operating systems. Use variables for paths.
    To make the platform apply applicative credentials while executing this command, use placeholders for credentials using the following syntax:
    • $$username$$ - for the user name
    • $$password$$ - for the password

    For example, a parsing command for a Microsoft SQL Server uses credential placeholders:

    "su - " + $userid + " -c '" + $ExecutableDir + "mysql --user=" + "$$username$$" + " --password=" + "$$password$$"

  3. To change the execution mode or credentials, click Advanced and fill in the fields, as appropriate.
    Field Description
    Execute Mode Select the relevant option for running this command:
    • Default (Remote) - on the remote device.
    • Local Script - on the MID Server
    • Windows Service - on the service running on the remote Windows server
    CI Type If necessary, select the CI type whose credentials the platform applies while running the command.
  4. To save the whole of the command output as a variable, select NONE from the Define Parsing list and define the variable as described in7 .
  5. Select the parsing strategy from the Define Parsing list.
    Parsing strategy Description

    Oracle

    LDAP file

    XML file

    INI file

    Properties file

    JSON file (custom)

    Horizontal file parsing strategy (not vertical). You can use this parsing strategy only for text files. For more information, see Parse text from a horizontal file.
    Vertical File Retrieve text from a structured text file where each set of data spans multiple lines. For more information, see Parse text from a vertical file.

    After Keyword

    Retrieve text directly following a specific keyword. For more information, see Parse text using keyword, command, and positional type.

    Command Line Java Style

    Retrieve the value of a command-line parameter using Java-style parameters. For more information, see Parse text using keyword, command, and positional type.

    Command Line Unix Style

    Retrieve the value of a command-line parameter using standard Unix parameters. For more information, see Parse text using keyword, command, and positional type.

    Position From End

    Retrieve text specified by its position from the end of the line. For more information, see Parse text using keyword, command, and positional type.

    Position From Start

    Retrieve text specified by its position from the beginning of the line. For more information, see Parse text using keyword, command, and positional type.

    Regular Expression Retrieve text specified by a regular expression. This option requires familiarity with Regex Java syntax. For more information, see Parse text using a regular expression.
    Delimited Text Retrieve text specified by delimiters and position within the line (the most common way to retrieve text from generic text files). See Parse text using delimited text.
  6. If working in Debug mode, perform the following steps:
    1. Click Run Command to see the result in the Output pane.
    2. In the Output pane, mark text or symbols that you want a variable to contain.
    3. In the variable name box, enter the name for the new variable, for example process_name.

      Defining a variable name for the string marked in the Output pane
    4. Press Enter.
      The new variable is added in the Variables pane.
  7. If not working in Debug mode, define the parsing criteria as follows:
    1. In the Variables pane, click Add Variable and enter the name for the new variable.
    2. Click the Advanced icon.

      Displaying the Advanced Variables pane
    3. Click Add Column Label.
    4. Enter the parsing query.
    5. Enter a value for the delimiter.
    6. Enter a value for the position.
  8. Select Use Cache to save the operation results in cache on the MID Server.
    Use cache to optimize discovery and avoid creating unnecessary load on central shared components, such as load balancers. The base system keeps operation results in cache for an hour.
  9. Select Terminate to stop the discovery process if no results are found.
  10. If in Debug mode, test the step by clicking Test and checking that the operation brings the result you expected.

Example

In this example, the Tibco parser script contained in the $TibcoParser variable runs on the target host. The parsing method is delimited text with the ‘=‘ delimiter. The result of the parsing is the path to the directory containing all configuration files for Tibco Business Works and Tibco Business Works Process. This step creates a temporary variable to hold the result of the parsing.


Example of the Parse Command Output operation

What to do next