Skip to content

Tag: <response> - Returns information

Definition

The <response> tag is used to return information from a task. It is used in the inventory, show_version tasks and within update_env commands.

This tag has the following attributes:

Parameters

  • line_nr (int) : Specifies the line to extract from. Count starts from 0.
  • token_nr (int) : Specifies the token number on the line to extract. Count starts from 1.
  • token_delimiter (str) : Specifies the delimiter used to separate tokens on a line. When not supplied the default is a single or a group of spaces.
  • offset (int) : Specifies the number of characters on the line to skip before capturing the text. Used with the length attribute. Count starts from 1.
  • length (int) : Specifies the number of characters to capture, starting from offset. Count starts from 1.

Both offset and length can both be used together with line_nr.

Example: Line and Token Number

If the command returns a predictable series of lines and words separated by spaces, then line_nr and word_nr can be used to extract the required information.

1
2
3
4
5
   <task name='inventory_task' type='namevalue'>
      <commands>
         <command format='output_text' valuename='hw_version'>tmsh show sys hardware
            <response line_nr='15' token_nr='1'/>
         </command>

In this example the command run produces several lines of output. The 15th line is selected and the first token on that line is extracted out and placed in the field hw_version.

Example: Token Delimiter

Other delimiters can also be specified, for example:

1
2
3
4
5
   <task name='inventory_task' type='namevalue'>
      <commands>
         <command format='output_text' select_lines_strip='NetScaler NS' valuename='sw_version'>show version
            <response token_delimiter=':' token_nr='0'/>
          </command>

In this example this device outputs a series of bits of information separated by colons, so the token_delimiter attribute is used to set the delimiter to be a colon, then the first token is extracted which is the actual version string.

Example: Offset and Length

Data can also be extracted by position, specified by and offset and a length, for example:

1
2
3
4
5
6
   <task name='inventory_task' type='namevalue'>
      <commands>
         ...
         <command format='output_text' valuename='hw_version'>show version
            <response line_nr='1' offset='11' length='24'/>
         </command>

There the hardware version of this devices is on line 2 (counting from 0), starting from the 11th character and is 24 characters long. Trailing spaces are automatically removed.

Parent Tags

Child Tags

  • None