N1 Grid Service Provisioning System 5.0 XML Schema Reference Guide

<execNative> Step

The <execNative> step executes a command native to the operating system on the target host. If the command produces an unexpected result, the step fails and execution stops.

The <execNative< step has the following child elements:

Attributes for the <execNative> Step

The <execNative> step has the following attributes:

<env> Element

The <execNative> element can optionally have <env> elements to specify environment variables for the command. You can use <env> to supply new variables for the command's environment or to override existing variables.

The set of the command's environment variables is a union of the set of the remote agent's environment variables and the variables supplied by using the <env> elements.

Attributes for the <env> Element

The <env> element has the following attributes. They can reference simple substitution variables.

<background> Element

The <background> element is a child of the <execNative> element. When present, this element specifies that the command should be executed as a background process. This element has no attributes or child elements.

An <execNative> with a <background> element has the following constraints:

<outputFile> Element

The <outputFile> element is a child of the <execNative> element. The <outputFile> element specifies the path to a local file on the agent in which to store the standard output of the command that is being executed. Specify the path to the local file by using the <outputFile> name attribute. Relative paths are interpreted as being relative to the command's working directory.

You must specify the <outputFile> element if you specify the <background> element.

If <outputFile> is not specified and the <successCriteria> element does not specify outputMatches, the command output is not stored and will be lost. If outputMatches is specified, the standard output is stored in a temporary file that is deleted after the command finishes executing.

Attributes for the <outputFile> Element

The <outputFile> element has one required attribute, name, which is the name of the file to which the standard output of the command is written. This value should be a nonempty string. This attribute can reference simple substitution variables.

<errorFile> Element

The <errorFile> element specifies the path to a local file on the agent in which to store the error output of the command that is being executed. The path to the local file is specified by using the <errorFile> name attribute. Relative paths are interpreted as being relative to the command's working directory.

You must specify the <errorFile> element if you specify the <background> element.

If <errorFile> is not specified and the <successCriteria> element does not specify errorMatches, the command output is not stored and will be lost. If errorMatches is specified, the error output is stored in a temporary file that is deleted after the command finishes executing.

Attributes for the <errorFile> Element

The <errorFile> element has one required attribute, name, which is the name of the file to which the standard error output of the command is written. This value should be a nonempty string. This attribute can reference simple substitution variables.

<inputText> Element

The <inputText> element is a child element of the <execNative> element. This child element specifies the arbitrary text that should be used as standard input to the command. The text is specified as the contents of this element.


<execNative>
    <inputText>
        ls -l | fgrep `*test*' | sort -u > file.out
    </inputText>
    <command exec=”sh”/>
</execNative>

The body of the <inputText> element can be enclosed in a CDATA section to preserve the formatting of the input and to avoid parsing errors that might be caused by input that contains the & and < characters.

If the <inputText> is specified, it is always enclosed within a CDATA section when generating XML for the <execNative> step. All of the characters within <inputText> are passed as standard input to the command that is being executed. If <inputText> contains only white spaces, those white spaces are passed, exactly as specified, to the command that is being executed.

The contents of <inputText> are config-generated.

The <inputText> element has no attributes.

<inputFile> Element

The <inputFile> element is a child element of <execNative>. This child element specifies the path to a local file on the remote agent whose contents are used as standard input to the command being executed. The path to the local file is specified by using the <inputFile> name attribute.


Note –

The <inputFile> element cannot be used with the <inputText> element in an <execNative> command.


Attributes for the <inputFile> Element

The <inputFile> element as one required attribute, name, which is the file to act as standard input to the command. This value should be a nonempty string. If a relative path is specified, it is relative to the command's working directory. This attribute can reference simple substitution variables.

<exec> Element

An <execNative> step can contain only one <exec> element. The <exec> element specifies the details of the native command to be executed.

The <exec> element contains the following attributes:

<execNative> executes the command specified by cmd with the arguments in the order in which they are specified.

For example, the following <execNative> step executes the ps -fu sps command:


<execNative>
    <exec cmd=”ps”>
        <arg value=”-fu”/>
        <arg value=”sps”/>
    </exec>
</execNative>

The <exec> element has an optional child element, <arg>. Specify one <arg> element for each argument to the command that you want to execute.

The <arg> element has one required attribute, value, which is the argument value. This argument is supplied as the nth argument to the command, where <arg> is the nth child of the command element. This attribute can reference simple substitution variables.

Attributes for the <exec> Element

The <exec> element has one required attribute, cmd, which is the path of the command to execute. If the specified path is not absolute, the command is found by using the platform-specified PATH environment variable set for the remote agent. This value should be a nonempty string. This attribute can reference simple substitution variables.

<shell> Element

The <shell> element is a child element of <execNative>. The contents of the <shell> element specifies the command to be executed. The command to be executed is interpreted using an interpreter, which is specified by the cmd attribute. The command is executed by using sh -c “command” syntax for the platform. In this form, the cmd attribute must be specified to indicate the shell command to use to execute the command.

For example:


<execNative>
    <shell cmd=”/usr/bin/bash -c”>
        ls -l | fgrep `*test*' | sort -u > file.out
    </shell>
</execNative>

The previous <execNative> example executes the following command:


/usr/bin/bash -c `ls -l | fgrep `*test*' | sort -u > file.out'

To preserve formatting and to avoid XML parsing problems, the text contents of the command is always enclosed within a CDATA element when the XML representation is generated from the <execNative> step.

A command string cannot be empty or contain only white space characters. The command string is supplied exactly as it is specified, including surrounding white space, to the shell.

The contents of the <shell> element are config-generated.

Attributes for the <shell> Element

The <shell> element has one required attribute, cmd, which is the shell command in the sh -c syntax. The string should not contain any embedded quote characters. The string is parsed to retrieve the shell name and the arguments by using white space as delimiters. For example, /usr/bin/bash -c should be a nonempty string. This attribute can reference simple substitution variables.

<successCriteria> Element

The <successCriteria> element is a child element of <execNative>. This child element specifies the criteria to be used to evaluate whether an <execNative> step executed successfully. If this element is not specified, the default value is <successCriteria status=”0”/>.

If the specified <successCriteria> is empty, it is ignored.

If you specify <successCriteria/>, the step always succeeds no matter what output or exit code the command generated.

Attributes for the <successCriteria> Element

The <successCriteria> element has the following optional attributes. If more than one of the status, outputMatches, and errorMatches attributes are specified, they are ANDed together.