11-09-2015 03:02 PM
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?
11-10-2015 07:26 PM
11-13-2015 10:23 AM
Thanks Joe, I will try it and let you know.
11-13-2015 11:59 AM
It is kind of working, but I have multiple lines to send.
I can't find what the ASCII code is for carriage return.
Here is my code:
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 "$userline0"
action 9.04 cli command "$userline1 \013"
action 9.05 cli command "$userline2 \013"
action 9.06 cli command "$userline3 \013"
action 9.07 cli command "$userline4 \013"
action 9.98 cli command "\032"
action 9.99 cli command "exit"
11-13-2015 12:11 PM
You'll need to use the pattern keyword after each line to wait for the next. It might be easier to put everything in one variable, though. You can try:
action X cli command "$userline0" pattern ".*"
...
11-13-2015 12:14 PM
No, that didn't work.
I would love to join each line together but I can't seem to get append to work. I'd want to have the carriage returns in the final variable.
11-13-2015 12:48 PM
You need to use \012 for NL. And you need to do it all on one line. This should work:
action X cli command "$var1\012$var2\032"
11-13-2015 12:52 PM
Awesome....that worked.
It exposed a problem that I had resovled with if conditionals but those go out the window with this setup.
I guess I need to get back to getting all 5 variables stored in one variable.
11-13-2015 01:12 PM
I cant seem to append userline0 to userline1.
11-13-2015 01:33 PM
Not sure what you're trying, but this shoul work:
action X append userline0 $userline1
11-13-2015 01:36 PM
Here is what I have:
action 9.00 comment "#### Send Message ####"
action 9.01 set message "0"
action 9.10 append message \012
action 9.11 append message userline0\012
action 9.12 append message userline1\012
action 9.13 append message userline2\012
action 9.14 append message userline3\012
action 9.15 append message userline4\012
action 9.19 puts "###########\012 Results \012###########\012 $message"
action 9.99 cli command "exit"
This is the results:
###########
Results
###########
0
userline0
userline1
userline2
userline3
userline4
11-13-2015 01:38 PM
Looks like it's working to me. Did you perhaps mean to do:
action 9.11 append message $userline0\012
11-13-2015 01:42 PM
With or without the "$" it is not appending the value of the variable.
11-13-2015 01:44 PM
This is working for me on recent IOS:
event manager applet appendt
event none
action 1.0 set a "foo"
action 2.0 set b "bar"
action 3.0 append a "$b"
action 4.0 puts "$a"
Output is "foobar"
11-13-2015 01:48 PM
I just retyped each line, one by one:
action 9.00 comment "#### Send Message ####"
action 9.10 append userline0 "\012"
action 9.11 append userline0 " $userline1\012"
action 9.12 append userline0 " $userline2\012"
action 9.13 append userline0 " $userline3\012"
action 9.14 append userline0 " $userline4\012"
action 9.19 puts "###########\012 Results \012###########\012 $userline0"
action 9.99 cli command "exit"
The results are:
###########
Results
###########
Line:vty(0) | User: ---removed---
Line:vty(1) | User: ---removed---
0
0
0
So now it appears to be working. So I need to build a nested "if" to do the appending only if the var not equal "0".
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide