cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2479
Views
5
Helpful
12
Replies

what is causing EEM to add this extra out line to any cli show command

the eem applet that causes this output is:

action 0011 cli command "enable"
action 0012 cli command "sh run | i ^line vty"
action 0013 foreach line "$_cli_result" "\n"

 

when i run this with debug action cli activated i see this behavior of EEM:

R1#sh run | i ^line vty
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli
R1#_lib) : : OUT : line vty 0 3
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 4
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 5
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 6
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 7 15
*Nov 26 19:23:12.599: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
So the debug shows that this "R1# prompt line" is also part of the output in EEM of the sh run | i ^line vty command


this is strange as it does not appear on the normal direct cli output of the same command:
R1#sh run | i ^line vty
line vty 0 3
line vty 4
line vty 5
line vty 6
line vty 7 15
R1#stops here
if have yet to discover why the extra "prompt line" is generated by EEM or if i can somehow remove it...

1 Accepted Solution

Accepted Solutions

Dan Frey
Cisco Employee
Cisco Employee

The EEM and manual output both return six lines (vty 0 3 .. R1#) so the output returned is exactly the same.   If you want to remove the last line that is "$hostname#" there are string commands to make that happen.

 

event manager applet test
 event none
 action 0005 info type routername
 action 0010 cli command "enable"
 action 0012 cli command "show run | inc ^line vty"
 action 0020 string trimright "$_cli_result" "$_info_routername#"
 action 0030 puts "$_string_result"
 action 0040 puts "$_cli_result"
!
end

C1111#event manager run test
line vty 0 4
line vty 5 15

line vty 0 4
line vty 5 15
C1111#

C1111#

View solution in original post

12 Replies 12

Hello,

 

try and add action 0011:

 

action 0010 cli command "enable"
action 0011 cli commad "term length 0"
action 0012 cli command "sh run | i ^line vty"
action 0013 foreach line "$_cli_result" "\n"

 

Hi George,

 

Still happens with terminal length 0 added:

R1#conf t
R1(config)#event manager applet blank
R1(config-applet)# event none
R1(config-applet)# action 0005 cli command "enable"
R1(config-applet)# action 0010 cli command "terminal length 0"
R1(config-applet)# action 0020 cli command "sh run | i ^line vty"
R1(config-applet)#exit
R1(config)#end

R1#event manager run blank
R1#
*Nov 26 21:46:21.295: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : CTL : cli_open called.
*Nov 26 21:46:21.299: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : R1>
*Nov 26 21:46:21.299: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : IN : R1>enable
*Nov 26 21:46:21.359: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : R1#
*Nov 26 21:46:21.359: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : IN : R1#terminal length 0
*Nov 26 21:46:21.407: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : R1#
*Nov 26 21:46:21.407: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : IN : R1#sh run | i ^line vty
*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : line vty 0 3
*Nov 26 21:46:22.187:
R1#%HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : line vty 4
*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : line vty 5
*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : line vty 6
*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : line vty 7 15
-----this is the one----------*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : OUT : R1#
*Nov 26 21:46:22.187: %HA_EM-6-LOG: blank : DEBUG(cli_lib) : : CTL : cli_close called.
*Nov 26 21:46:22.187:
*Nov 26 21:46:22.191: tty is now going through its death sequence
R1#

 

 

the problem with something like an extra line out of a cli command that includes the prompt is f.i. if you want to go further and process that cli output in a foreach line loop , then this becomes something to deal with as it is an unwanted line that can mess up the rest of your script/applet logic..

 

Dan Frey
Cisco Employee
Cisco Employee

The EEM and manual output both return six lines (vty 0 3 .. R1#) so the output returned is exactly the same.   If you want to remove the last line that is "$hostname#" there are string commands to make that happen.

 

event manager applet test
 event none
 action 0005 info type routername
 action 0010 cli command "enable"
 action 0012 cli command "show run | inc ^line vty"
 action 0020 string trimright "$_cli_result" "$_info_routername#"
 action 0030 puts "$_string_result"
 action 0040 puts "$_cli_result"
!
end

C1111#event manager run test
line vty 0 4
line vty 5 15

line vty 0 4
line vty 5 15
C1111#

C1111#

Many thanks Daniel! That will work

 

Hi Daniel,

 

if i trim the prompt that way, i noticed that the blank still gets processed and that a problem if your configuring the vty lines with command as i will then go like:

conf t

blank

tranport input ssh (fails as your not in any vty line )

all following commands will fail too

the only way i found around this is to regex match on line vty and if not equal then exit

So yeah its still bothersome that that extra router prompt is not entirely removed as after

the trim a blank line is still left that still will be processed 

Are you saying there is a new line on the router prompt that is remaining?   If so then use this line to remove the router prompt and new line.   If its something else could you post the entire EEM policy and  provide some additional details?

 

 action 0020 string trimright "$_cli_result" "$_info_routername#\n"

Hi Daniel,

 

thanks again for helping here, however i feel like im loosing my mind here

 

look what happens here:

 

the output of sh run | s ^line vty is this:

R1#sh run | i ^line vty
line vty 0 3
line vty 4
line vty 5
line vty 6
line vty 7 15
R1#

then, i ran the suggestion you made with "$_info_routername#\n" and added the string length to see what is detected when it is used:

R1#event manager run tri
13
11
11
11
14
0-----so yes this looks good right

R1#

But then tested it in my applet,  after the last vty line , vty 7 15, is processed, look what happens:

It looks like the blank is still there

 

R1#conf t
R1(config)#event manager applet trim
R1(config-applet)#event none maxrun 300
R1(config-applet)#action 0001 info type routername
R1(config-applet)#action 0002 cli command "enable"
R1(config-applet)#action 0003 cli command "sh run | i ^line vty"
R1(config-applet)#action 0004 foreach line "$_cli_result" "\n"
R1(config-applet)#action 0005 string trimleft "$line" "$_info_routername#\n"
R1(config-applet)#$ regexp "(line vty\s[^4].*)" "$_string_result" match
R1(config-applet)#action 0007 if $_regexp_result eq 1
R1(config-applet)#action 0008 cli command "conf t"
R1(config-applet)#action 0009 cli command "$match"
R1(config-applet)#action 0010 cli command "privilege level 15"
R1(config-applet)#action 0011 cli command "end"
R1(config-applet)#action 0012 else
R1(config-applet)#action 0013 cli command "conf t"
R1(config-applet)#action 0014 cli command "$_string_result"
R1(config-applet)#action 0015 cli command "transport input telnet"
R1(config-applet)#action 0016 cli command "transport output telnet"
R1(config-applet)#action 0017 cli command "end"
R1(config-applet)#action 0019 end
R1(config-applet)#action 0020 end
R1(config-applet)#exit
R1(config)#end
R1#event manager run trim
*Nov 27 21:42:21.839: %SYS-5-CONFIG_I: Configured from console by console
R1#event manager run trim

*Nov 27 21:42:25.083: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : CTL : cli_open called.
*Nov 27 21:42:25.083: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:25.083: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#enable
*Nov 27 21:42:25.099: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:25.099: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#sh run | i ^line vty
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : line vty 0 3
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : line vty 4
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : line vty 5
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : line vty 6
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : line vty 7 15
*Nov 27 21:42:26.119: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:26.131: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:26.183: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:26.183: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:26.183: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#line vty 0 3
*Nov 27 21:42:26.199: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.199: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.199: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#privilege level 15
*Nov 27 21:42:26.275: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.275: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 21:42:26.275: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:trim)
*Nov 27 21:42:26.291: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
R1#v 27 21:42:26.291: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:26.339: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:26.339: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:26.339: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#line vty 4
*Nov 27 21:42:26.383: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.383: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.383: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#transport input telnet
*Nov 27 21:42:26.507: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.507: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#transport output telnet
*Nov 27 21:42:26.555: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.555: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 21:42:26.555: %SYS-5-CONFIG_I: Co
R1#nfigured from console by on vty1 (EEM:trim)
*Nov 27 21:42:26.571: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:26.571: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:26.615: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:26.615: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:26.615: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#line vty 5
*Nov 27 21:42:26.631: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.631: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#privilege level 15
*Nov 27 21:42:26.679: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.679: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.679: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 21:42:26.679: %SYS-5-CONFIG_I: Confi
R1#gured from console by on vty1 (EEM:trim)
*Nov 27 21:42:26.727: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:26.727: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:26.771: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:26.771: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:26.771: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#line vty 6
*Nov 27 21:42:26.819: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.819: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.819: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#privilege level 15
*Nov 27 21:42:26.867: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.867: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 21:42:26.867: %SYS-5-CONFIG_I: Configur
R1#ed from console by on vty1 (EEM:trim)
*Nov 27 21:42:26.911: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:26.911: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:26.959: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:26.959: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:26.959: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#line vty 7 15
*Nov 27 21:42:26.975: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.975: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:26.975: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#privilege level 15
*Nov 27 21:42:27.023: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 21:42:27.023: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 21:42:27.023: %SYS-5-CONFIG_I: Configur
R1#ed from console by on vty1 (EEM:trim)
*Nov 27 21:42:27.067: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:27.067: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 21:42:27.147: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 21:42:27.147: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:27.147: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#
*Nov 27 21:42:27.195: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:27.195: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#transport input telnet
*Nov 27 21:42:27.259: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : ^
*Nov 27 21:42:27.263: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.
*Nov 27 21:42:27.263: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT :
*Nov 27 21:42:27.267: %HA_EM-6-LOG: trim : DEBUG(cli_lib) :
R1#: OUT : R1(config)#
*Nov 27 21:42:27.271: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#transport output telnet
*Nov 27 21:42:27.319: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : ^
*Nov 27 21:42:27.319: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : % Invalid input detected at '^' marker.
*Nov 27 21:42:27.319: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT :
*Nov 27 21:42:27.319: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 21:42:27.319: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : IN : R1(config)#end
*Nov 27 21:42:27.319: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:trim)
*Nov 27 21:42:27.335: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 21:42:27.335: %HA_EM-6-LOG: trim : DEBUG(cli_lib) : : CTL : cli_close called.
*Nov 27 21:42:27.339:
*Nov 27 21:42:27.343: tty is now going through its death sequence
R1#

 

Dan Frey
Cisco Employee
Cisco Employee

It appears you want to put transport input/output telnet and privilege level 15 commands on all existing VTY lines of the device?  I do not understand why you are using if/else in the script and not feeding the priv and transport commands without the "if" statement and why $_string_result is being fed in as a single command?    Another option is to feed the commands in without iterating over $_cli_result.

event manager applet trim
 event none
 action 010 cli command "enable"
 action 020 cli command "show line | count VTY"
 action 030 regexp "regexp = ([0-9]+)" "$_cli_result" match lines
 action 040 subtract $lines 1
 action 045 puts "lines = $_result"
 action 050 cli command "conf t"
 action 060 cli command "line vty 0 $_result"
 action 070 cli command "privilege level 15"
 action 080 cli command "transport input telnet"
 action 090 cli command "transport output telnet"

Hi Daniel,

thanks to your help of puting me on the trail of the $_info_routername#

I finally got it..using string equal i was able to get rid of the blank by skipping it when detected! :

R1#conf t
R1(config)#event manager applet no_vty_telnet authorization bypass
R1(config-applet)#event none maxrun 300
R1(config-applet)#action 0001 info type routername
R1(config-applet)#action 0002 cli command "enable"
R1(config-applet)#action 0003 cli command "sh run | i ^line vty"
R1(config-applet)#action 0004 foreach line "$_cli_result" "\n"
R1(config-applet)#action 0005 string equal "$line" "$_info_routername#"
R1(config-applet)#action 0006 if "$_string_result" eq 1
R1(config-applet)#action 0007 continue
R1(config-applet)#action 0008 else
R1(config-applet)#action 0009 regexp "(line vty\s[0-9].*)" "$line" match
R1(config-applet)#action 0010 if $_regexp_result eq 1
R1(config-applet)#action 0011 cli command "conf t"
R1(config-applet)#action 0012 cli command "$line"
R1(config-applet)#action 0013 cli command "transport input ssh"
R1(config-applet)#action 0014 cli command "transport output ssh"
R1(config-applet)#action 0015 cli command "end"
R1(config-applet)#action 0024 end
R1(config-applet)#action 0025 end
R1(config-applet)#action 0026 end
R1(config-applet)#exit
R1(config)#end
R1#event manager run no_vty_telnet authorization bypass
*Nov 27 23:03:34.171: %SYS-5-CONFIG_I: Configured from console by console
R1#event manager run no_vty_telnet authorization bypass

*Nov 27 23:03:42.643: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : CTL : cli_open called.
*Nov 27 23:03:42.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:42.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#enable
*Nov 27 23:03:42.707: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:42.707: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#sh run | i ^line vty
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 0 3
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 4
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 5
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 6
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 7 15
*Nov 27 23:03:43.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:0
R1#3:43.511: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:03:43.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:03:43.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:03:43.663: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 0 3
*Nov 27 23:03:43.719: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.719: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.719: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:03:43.763: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.763: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:03:43.811: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT
R1# : R1(config-line)#
*Nov 27 23:03:43.811: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:03:43.811: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:03:43.827: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:43.827: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:03:43.871: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:03:43.871: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:03:43.871: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 4
*Nov 27 23:03:43.919: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.919: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.919: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line
R1#)#transport input ssh
*Nov 27 23:03:43.967: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:43.967: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:03:44.011: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.011: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:03:44.011: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:03:44.055: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:44.055: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:03:44.103: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:03:44.103: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:03:44.103: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN :
R1# R1(config)#line vty 5
*Nov 27 23:03:44.119: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.119: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.119: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:03:44.163: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.163: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:03:44.211: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.211: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:03:44.211: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:03:44.255: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:44.255: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t

R1#*Nov 27 23:03:44.303: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:03:44.303: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:03:44.303: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 6
*Nov 27 23:03:44.351: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.351: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.351: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:03:44.399: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.399: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:03:44.447: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.447: %HA_EM-6-LOG: no_vty_telnet : DEBUG
R1#(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:03:44.447: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:03:44.495: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:44.495: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:03:44.543: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:03:44.543: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:03:44.543: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 7 15
*Nov 27 23:03:44.587: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.587: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.587: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:03:44.635: %HA_EM-6-LOG: no_vty_telnet :
R1#DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.635: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:03:44.683: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:03:44.683: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:03:44.683: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:03:44.699: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:03:44.699: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : CTL : cli_close called.
*Nov 27 23:03:44.715:
*Nov 27 23:03:44.715: tty is now going through its death sequence
R1#


 

or simpler yet:

this one also removes the "routerprompt" line, as it demands the match to be equal to the regex, and the "routerprompt" is not part of the party:

 

conf t
event manager applet no_vty_telnet authorization bypass
event none maxrun 300
action 0002 cli command "enable"
action 0003 cli command "sh run | i ^line vty"
action 0004 foreach line "$_cli_result" "\n"
action 0009 regexp "(line vty\s[0-9].*)" "$line" match
action 0010 if $_regexp_result eq 1
action 0011 cli command "conf t"
action 0012 cli command "$match"
action 0013 cli command "transport input ssh"
action 0014 cli command "transport output ssh"
action 0015 cli command "end"
action 0024 end
action 0025 end
exit
end
event manager run no_vty_telnet authorization bypass

*Nov 27 23:29:34.739: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : CTL : cli_open called.
*Nov 27 23:29:34.755: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:34.755: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#enable
*Nov 27 23:29:34.799: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:34.799: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#sh run | i ^line vty
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 0 3
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 4
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 5
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 6
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : line vty 7 15
*Nov 27 23:29:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:2
R1#9:35.503: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:29:35.519: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:29:35.519: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:29:35.519: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 0 3
*Nov 27 23:29:35.563: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.563: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.563: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:29:35.627: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.627: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:29:35.643: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT
R1# : R1(config-line)#
*Nov 27 23:29:35.643: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:29:35.651: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:29:35.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:35.659: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:29:35.707: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:29:35.707: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:29:35.707: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 4
*Nov 27 23:29:35.739: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.739: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.739: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line
R1#)#transport input ssh
*Nov 27 23:29:35.775: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.775: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:29:35.815: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.815: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:29:35.815: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:29:35.863: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:35.863: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:29:35.907: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:29:35.907: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:29:35.907: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN :
R1# R1(config)#line vty 5
*Nov 27 23:29:35.923: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.923: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.923: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:29:35.971: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:35.971: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:29:36.019: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.019: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:29:36.019: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:29:36.063: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:36.063: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t

R1#*Nov 27 23:29:36.111: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:29:36.111: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:29:36.111: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 6
*Nov 27 23:29:36.127: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.127: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.127: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:29:36.171: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.171: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:29:36.219: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.219: %HA_EM-6-LOG: no_vty_telnet : DEBUG
R1#(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:29:36.219: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:29:36.263: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:36.263: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1#conf t
*Nov 27 23:29:36.311: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : Enter configuration commands, one per line. End with CNTL/Z.
*Nov 27 23:29:36.311: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config)#
*Nov 27 23:29:36.311: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config)#line vty 7 15
*Nov 27 23:29:36.355: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.355: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.355: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport input ssh
*Nov 27 23:29:36.403: %HA_EM-6-LOG: no_vty_telnet :
R1#DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.403: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#transport output ssh
*Nov 27 23:29:36.447: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1(config-line)#
*Nov 27 23:29:36.447: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : IN : R1(config-line)#end
*Nov 27 23:29:36.447: %SYS-5-CONFIG_I: Configured from console by on vty1 (EEM:no_vty_telnet)
*Nov 27 23:29:36.495: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : OUT : R1#
*Nov 27 23:29:36.495: %HA_EM-6-LOG: no_vty_telnet : DEBUG(cli_lib) : : CTL : cli_close called.
*Nov 27 23:29:36.499:
*Nov 27 23:29:36.503: tty is now going through its death sequence
R1#

 

Jakob Mellberg
Level 1
Level 1

I had the same issue where I got a blank line in my regexp.
I solved it by using \r to stop the match

event manager applet test
event none
action 0010 cli command "enable"
action 0020 cli command "show running-config interface ten 1/1/2 | include description .*"
action 0030 regexp "description (.+)\r" "$_cli_result" match current_description
action 0040 syslog msg "CURRENT: $current_description"
end

event manager run test

#show history all
CMD: 'event manager run test' 15:51:23 CEST Thu Oct 26 2023
CMD: 'enable' 15:51:23 CEST Thu Oct 26 2023
CMD: 'show running-config interface ten 1/1/2 | include description .*' 15:51:23 CEST Thu Oct 26 2023
011066: Oct 26 13:51:24.033: %HA_EM-6-LOG: test: CURRENT: SDA-FABRIC-BN2 - TwentyFiveGigE1/0/1
CMD: 'sh hist all' 15:51:24 CEST Thu Oct 26 2023

 

Review Cisco Networking for a $25 gift card