Handling Special Characters in Action Arguments

In some cases, NNMi requires or inserts double quotes or escape characters in arguments that are passed to the Jython file, executable, or shell script using the Command attribute.

Note Shell commands are not permitted in the Command attribute. If you use shell commands, place them in a shell script file and reference that file from the Command attribute.

The following table describes how to handle special characters included as arguments to your Jython files, executables, or shell scripts.

Handling Special Characters in Arguments
Circumstance Result

If the following special characters are requested as a single argument to a Jython, executable, shell script, or shell command:

,  ;  &  >  <  (space)  | =

The argument (containing the special character) must be wrapped in double quotes. For example, "Hello;World".

Request all available CIA name/value pairs for a particular incident

$*

The $* argument returns a parsed string. For this example, the available CIA name/value pairs are:

  • $1 = 123
  • $com.mycompany.mycia = 012345
  • $.1.3.6.1.2.1.2.2.1.1 = 1007

Example Command

echoScript.bat $*

NNMi returns the following string in response to the command:

  • Windows:
    "1: 123, com.mycompany.mycia:012345, .1.3.6.1.2.1.2.2.1.1:1007"
  • Linux:
    1: 123, com.mycompany.mycia:012345, .1.3.6.1.2.1.2.2.1.1:1007

Request specific CIA values as an argument to an action command

$<CIA name, position, or OID>

To request specific CIA values, use the $ followed by the CIA name

Example Command

echoScript.bat $1   $com.mycompany.mycia   $.1.3.6.1.2.1.2.2.1.1 

For this example, the CIA name/value pairs are:

  • $1 = 123
  • $com.mycompany.mycia = 012345
  • $.1.3.6.1.2.1.2.2.1.1 = 1007

 NNMi returns the following string in response to the command:

  • Windows:
    123 012345 1007
  • Linux:
    123 012345 1007
If an invalid CIA name, position, or OID is requested as an argument to an action command

If the trap or event does not contain one or more of the requested CIAs, NNMi passes error messages as arguments.

Linux:

Invalid or unknown cia position 1

Invalid or unknown cia com.mycompany.mycia

Invalid or unknown cia .1.3.6.1.2.1.2.2.1.1

Windows: NNMi encloses each CIA value in double quotes.

Invalid or unknown cia "position 1" 

Invalid or unknown cia "com.mycompany.mycia"

Invalid or unknown cia ".1.3.6.1.2.1.2.2.1.1"

Use $* in your incident action scripts

Linux:

It is recommended that you do not use $* (shell variable substitution) in your incident action scripts. If you do use $* within the shell script, specifying $* expands into the arguments and are rescanned. This means that blanks in arguments will result in multiple arguments.

If you want to use shell variable substitution, use the "$@" instead so that blanks in arguments are ignored.

Use arguments to Jython methods Enclose any argument that is not preceded with a "$" (dollar sign) in double quotes. For example, jythonMethod($Severity, "Hello; World").