<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: EEM Could Not Find Environment Variable - Using $_cli_result in Network Devices</title>
    <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902453#M386</link>
    <description>&lt;P&gt;So after playing with it a little longer and doing a few more tests. I can say it is for some reason not liking my regex syntax and is not finding the match it is expecting. So below are the tests im doing.&lt;/P&gt;&lt;P&gt;MAC Being used:&amp;nbsp;0050.db01.0203&lt;/P&gt;&lt;P&gt;When using&amp;nbsp;&lt;/P&gt;&lt;P&gt;action 1.3 regexp "(0-9a-f){4}(\.)(0-9a-f){2}" "$_cli_result" mac_address&lt;/P&gt;&lt;P&gt;action 1.4 syslog msg "$mac_address is the matched MAC Address"&lt;/P&gt;&lt;P&gt;Result: getting reported error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I use specific parts of the MAC (in todays case "0050.db") with the below regex:&lt;/P&gt;&lt;P&gt;action 1.3 regexp "0050" "$_cli_result" mac_address&lt;/P&gt;&lt;P&gt;action 1.4 syslog msg "$mac_address is the matched MAC Address"&lt;/P&gt;&lt;P&gt;Result:&amp;nbsp;%HA_EM-6-LOG: TEST: 0050 is the matched MAC Address&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone might be able to identify what is incorrect in the regex it would be appreciated. I will also keep this updated if I happen to find a fix for other learners sake.&lt;/P&gt;</description>
    <pubDate>Wed, 09 Aug 2023 15:25:29 GMT</pubDate>
    <dc:creator>ChrisCameron2250</dc:creator>
    <dc:date>2023-08-09T15:25:29Z</dc:date>
    <item>
      <title>EEM Could Not Find Environment Variable - Using $_cli_result</title>
      <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902004#M383</link>
      <description>&lt;P&gt;Hello all. I have been bashing my head on the desk all day trying to solve this issue. I feel like im just an inch away from figuring it out but I keep getting the same error which is stopping me dead in my EEM test I'm trying to do. What I am trying to do is capture the OUI of a device connected to an interface and compare it with a known value, if it matches it will do something. Below is the configuration on my test EEM as well as the error message I am getting when I run the applet. If you would happen to know what I am missing I would appreciate it greatly! Please let me know if you would like any additional information. I have been scouring the forums and other sources looking for answers and have adjusted the regex a few times.&lt;/P&gt;&lt;P&gt;** CONFIG **&lt;/P&gt;&lt;P&gt;event manager applet TEST&lt;BR /&gt;event none&lt;BR /&gt;action 0.0 cli command "enable"&lt;BR /&gt;action 1.0 cli command "show mac add int g1/0/3"&lt;BR /&gt;action 1.1 regexp "(a-f0-9){4}(\.)(a-f0-9){2}" "$_cli_result" mac_address&lt;BR /&gt;action 1.2 if $mac_address eq "7c57.58"&lt;BR /&gt;action 1.3 syslog msg "Found $mac_address - Proceeding with configuration"&lt;BR /&gt;action 1.4 end&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;** ERROR WHEN RUNNING APPLET **&lt;/P&gt;&lt;P&gt;%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: mac_address&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 04:38:47 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902004#M383</guid>
      <dc:creator>ChrisCameron2250</dc:creator>
      <dc:date>2023-08-09T04:38:47Z</dc:date>
    </item>
    <item>
      <title>Re: EEM Could Not Find Environment Variable - Using $_cli_result</title>
      <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902167#M384</link>
      <description>&lt;P&gt;Been a while since I’ve done any EEM.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The error message "%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: mac_address" means that the EEM applet is trying to use an environment variable called &lt;/SPAN&gt;mac_address&lt;SPAN&gt;, but that environment variable does not exist. This is because the &lt;/SPAN&gt;regexp&lt;SPAN&gt; action in the applet is trying to extract the MAC address from the output of the &lt;/SPAN&gt;show mac add int g1/0/3&lt;SPAN&gt; command, but it is not storing the output of the command in an environment variable.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;To fix this error, you need to add an action to the applet to store the output of the show mac add int g1/0/3 command in an environment variable. The following action will do this:&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;action 1.0 cli command "show mac add int g1/0/3" store output into $_cli_result&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;This will store the output of the show mac add int g1/0/3 command in an environment variable called $_cli_result. The regexp action can then use this environment variable to extract the MAC address.&lt;/P&gt;&lt;P&gt;The updated EEM applet would look like&lt;/P&gt;&lt;DIV class=""&gt;&lt;PRE&gt;event manager applet TEST
event none
action 0.0 cli command "enable"
action 1.0 cli command "show mac add int g1/0/3" store output into $_cli_result
action 1.1 regexp "(a-f0-9){4}(\.)(a-f0-9){2}" "$_cli_result" mac_address
action 1.2 if $mac_address eq "7c57.58"
action 1.3 syslog msg "Found $mac_address - Proceeding with configuration"
action 1.4 end&lt;/PRE&gt;&lt;/DIV&gt;&lt;P&gt;Once you have updated the applet, It should work. LMK&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 10:36:27 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902167#M384</guid>
      <dc:creator>bigevilbeard</dc:creator>
      <dc:date>2023-08-09T10:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: EEM Could Not Find Environment Variable - Using $_cli_result</title>
      <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902260#M385</link>
      <description>&lt;P&gt;Thank you for helping with this beard! I did try to modify my applet, but it is giving me invalid input at store. Looks like it is expecting "pattern" or enter. This is being setup on a WS-C3560CX-12PC-S Version: 15.2(7)E7.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 12:25:28 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902260#M385</guid>
      <dc:creator>ChrisCameron2250</dc:creator>
      <dc:date>2023-08-09T12:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: EEM Could Not Find Environment Variable - Using $_cli_result</title>
      <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902453#M386</link>
      <description>&lt;P&gt;So after playing with it a little longer and doing a few more tests. I can say it is for some reason not liking my regex syntax and is not finding the match it is expecting. So below are the tests im doing.&lt;/P&gt;&lt;P&gt;MAC Being used:&amp;nbsp;0050.db01.0203&lt;/P&gt;&lt;P&gt;When using&amp;nbsp;&lt;/P&gt;&lt;P&gt;action 1.3 regexp "(0-9a-f){4}(\.)(0-9a-f){2}" "$_cli_result" mac_address&lt;/P&gt;&lt;P&gt;action 1.4 syslog msg "$mac_address is the matched MAC Address"&lt;/P&gt;&lt;P&gt;Result: getting reported error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However when I use specific parts of the MAC (in todays case "0050.db") with the below regex:&lt;/P&gt;&lt;P&gt;action 1.3 regexp "0050" "$_cli_result" mac_address&lt;/P&gt;&lt;P&gt;action 1.4 syslog msg "$mac_address is the matched MAC Address"&lt;/P&gt;&lt;P&gt;Result:&amp;nbsp;%HA_EM-6-LOG: TEST: 0050 is the matched MAC Address&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If anyone might be able to identify what is incorrect in the regex it would be appreciated. I will also keep this updated if I happen to find a fix for other learners sake.&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 15:25:29 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902453#M386</guid>
      <dc:creator>ChrisCameron2250</dc:creator>
      <dc:date>2023-08-09T15:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: EEM Could Not Find Environment Variable - Using $_cli_result</title>
      <link>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902500#M387</link>
      <description>&lt;P&gt;Additional Info:&lt;BR /&gt;It seems like the regex is not finding matches with the {4} expression. Tests and Results below:&lt;/P&gt;&lt;P&gt;Test 1: Without {4}&lt;/P&gt;&lt;P&gt;action 1.3 regexp "(.*)" $_cli_result mac_address&lt;/P&gt;&lt;P&gt;Result:&lt;/P&gt;&lt;P&gt;Aug 9 13:19:39.809 EDT: %HA_EM-6-LOG: TEST: Mac Address Table&lt;BR /&gt;-------------------------------------------&lt;/P&gt;&lt;P&gt;Vlan Mac Address Type Ports&lt;BR /&gt;---- ----------- -------- -----&lt;BR /&gt;10 0050.db01.0203 DYNAMIC Gi0/3&lt;BR /&gt;Total Mac Addresses for this criterion: 1&lt;BR /&gt;C3560X-13-101# is the matched MAC Address&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Test 2: With (00.*)&lt;/P&gt;&lt;P&gt;action 1.3 regexp "(00.*)" $_cli_result mac_address&lt;/P&gt;&lt;P&gt;Result:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Aug 9 13:20:14.032 EDT: %HA_EM-6-LOG: TEST: 0050.db01.0203 DYNAMIC Gi0/3&lt;BR /&gt;Total Mac Addresses for this criterion: 1&lt;BR /&gt;C3560X-13-101# is the matched MAC Address&lt;/P&gt;&lt;P&gt;Test 3: With {4}&lt;/P&gt;&lt;P&gt;action 1.3 regexp "(00.*){4}" $_cli_result mac_address&lt;/P&gt;&lt;P&gt;Result:&lt;BR /&gt;Aug 9 13:20:50.766 EDT: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: mac_address&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Aug 2023 17:28:36 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-devices/eem-could-not-find-environment-variable-using-cli-result/m-p/4902500#M387</guid>
      <dc:creator>ChrisCameron2250</dc:creator>
      <dc:date>2023-08-09T17:28:36Z</dc:date>
    </item>
  </channel>
</rss>

