cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3073
Views
0
Helpful
17
Replies

EEM Applet to send a message to VTY lines

Jason Kopacko
Level 4
Level 4

No matter what I do, I can't seem to get an EEM script to send a message to all VTY lines. I am sure it is something ASCII related, but not sure what the fix is.

I have a script that, for now, collects all currently logged in users as my test, and then sends the info to the VTY lines.

$userline0 = is my variable that holds the usernames

====================================
action 9.22 cli command "enable"
action 9.23 cli command "send vty 1"
action 9.24 cli command "$userline0"
action 9.25 cli command "\032"
action 9.26 cli command "\x0a"
====================================

Any advice as how to proceed?

17 Replies 17

Well, it didnt quite work:


action 8.00 comment "#### Build Message ####"
action 8.01 if $userline1 ne "0"
action 8.02 append userline0 " $userline1\012"
action 8.10 if $userline2 ne "0"
action 8.11 append userline0 " $userline2\012"
action 8.20 if $userline3 ne "0"
action 8.21 append userline0 " $userline3\012"
action 8.30 if $userline4 ne "0"
action 8.31 append userline0 " $userline4\012"
action 8.40 end
action 8.41 end
action 8.42 end
action 8.43 end

action 9.00 comment "#### Send Message ####"
action 9.19 puts "\012###########\012 Results \012###########\012 $userline0"
action 9.99 cli command "exit"

The results are (all one line):

###########
Results
###########
Line:vty(0) | User: ---removed--- Line:vty(1) | User: ---removed---

I don't follow.  Are you saying that with the if statements, the \012 is not working and the results all come on one line?

I got it! Thank you soooooo much Joe. Here is the final code:

 action 8.00 comment "#### Build Message ####"
action 8.01 set users "\012###########\012 Results \012###########\012"
action 8.02 append users "$userline0\012"
action 8.10 if $userline1 ne "0"
action 8.11 append users "$userline1\012"
action 8.20 if $userline2 ne "0"
action 8.21 append users "$userline2\012"
action 8.30 if $userline3 ne "0"
action 8.31 append users "$userline3\012"
action 8.40 if $userline4 ne "0"
action 8.41 append users "$userline4\012"
action 8.50 end
action 8.51 end
action 8.52 end
action 8.53 end

action 9.00 comment "#### Send Message ####"
action 9.01 cli command "enable"
action 9.02 cli command "send *" pattern "CTRL/C:"
action 9.03 cli command "$users\032"
action 9.99 cli command "exit"
exit
!

And the results are (this popped up as soon as I logged in from another session):


***
***
*** Message from tty390 to all terminals:
***

###########
Results
###########
Line:con(0) | User: ---removed---(Console)
Line:vty(0) | User: ---removed---(0.0.0.0)
Line:vty(1) | User: ---removed---(0.0.0.0)