cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
684
Views
0
Helpful
4
Replies

EEM - trying to get output from 2 variables into one line

astrosfan11dcs
Level 1
Level 1

I'm trying to get " description dvd-net-ap13 - 192.168.1.192 - 6849.92d0.3A54 " onto a single line so I can then use that to set the description of the port with this information. 

I cannot seem to get variables $_cli_result - $_string_result to return on a single line. In the debug it always returns $_cli_result as one line and $_string_result as another. 

 

Is there anyway to do what I'm looking for here? 

 

event manager applet test5 authorization bypass
event none
action 10 cli command "enable"
action 20 cli command "conf t"
action 30 cli command "int te1/0/13"
action 40 cli command "do sh mac add int te1/0/13 | begin 1"
action 50 set string $_cli_result
action 60 string range "$string" 8 21
action 70 puts $_string_result
action 80 cli command "do show run int te1/0/13 | inc description"
action 85 puts $_cli_result
action 90 cli command "$_cli_result - $_string_result"

 

switch#even man run test5
6849.92d0.3A54
description dvd-net-ap13 - 192.168.1.192

This is whats its doing 

%HA_EM-6-LOG: test5 : DEBUG(cli_lib) : : IN : switch(config-if)# description dvd-net-ap13 - 192.168.1.192
Feb 16 20:59:43.807 UTC: %HA_EM-6-LOG: test5 : DEBUG(cli_lib) : : IN : switch(config-if)# - 6849.92d0.3A54

 

 

 

 

4 Replies 4

astrosfan11dcs
Level 1
Level 1

Bump - also would consider any better way of doing this. Thanks 

astrosfan11dcs
Level 1
Level 1

Bump

Hello,

thanks to the input of @Dan Frey I have come up with the script below. It probably requires some adjustment...

event manager applet test5 authorization bypass
event none
action 1.0 cli command "enable"
action 2.0 cli command "conf t"
action 3.0 cli command "int te1/0/13"
action 4.0 cli command "do sh mac add int te1/0/13 | begin 1"
action 5.0 set string $_cli_result
action 6.0 string range "$string" 8 21
action 7.0 cli command "do show run int te1/0/13 | inc description"
action 8.0 file open fh flash:desc_mac.txt a+
action 8.1 file write fh "$_string_result"
action 8.2 file write fh "$_cli_result"
action 8.3 file close fh
action 8.4 file open fh flash:desc_mac.txt r
action 8.5 file read fh var
action 8.6 puts "$var"
action 8.7 file close fh

Dan Frey
Cisco Employee
Cisco Employee

Consolidate multiple variables into one.

event manager applet test
 event none
 action 010 set mac "6849.92d0.3A54"
 action 020 set desc "dvd-net-ap13 - 192.168.1.192"
 action 030 append mac "$desc"
 action 040 puts "$mac"

C1111#event manager run test
6849.92d0.3A54dvd-net-ap13 - 192.168.1.192