action string compare
To compare two unequal strings when an Embedded Event Manager (EEM) applet is triggered, use the action string compare command in applet configuration mode. To disable this function, use the no form of this command.
action label string compare [nocase] [length integer] string1 string2
no action label string compare
Syntax Description
label |
Unique identifier that can be any string value. Actions are sorted and run in ascending alphanumeric key sequence using the label as the sort key. If the string contains embedded blanks, enclose it in double quotation marks. |
nocase |
(Optional) Specifies case insensitive comparison. |
length |
(Optional) Limits the comparison to the first integer character. |
integer |
(Optional) Valid values for the length argument range from 1 to 4294967295. |
string1 |
Sequence of characters. |
string2 |
Sequence of characters. |
Command Default
Unequal strings are not compared.
Command Modes
Applet configuration (config-applet)
Command History
Release |
Modification |
---|---|
12.4(22)T |
This command was introduced. |
12.2(33)SRE |
This command was integrated into Cisco IOS Release 12.2(33)SRE. |
Usage Guidelines
String comparisons are performed on a byte-by-byte basis from left to right. If the strings are of unequal length, the longer string is compared greater than the shorter string. The action string compare command forces a comparison between two unequal strings, which is followed by an integer comparison of the result of the string comparison.
When two equal strings are compared, the result is 0 and when one string sorts before the other, the result is -1. For all other comparisons the result is 1. If the strings being compared are converted to integers, the comparison is performed between the results using the strcmp command.
The table below shows the built-in variable in which the results of the action string compare command are stored.
Built-in Variable |
Description |
---|---|
$_string_result |
The result of the action string compare command is stored in this variable. |
Examples
The following example shows how to compare two unequal strings:
Router(config-applet)# event manager applet compare
Router(config-applet)# event none
Router(config-applet)# action 1 set str "this contains some $str"
Router(config-applet)# action 2 string compare nocase length 3 “contains” “$str”