09-21-2013 07:49 AM
Hello, I am going to make use of EEM scripting to send to my ftp server some interfaces stats, I´m working with a cisco 3750. However, I´m seeing on event manager history events, that my EEM script (below) is aborted.I think that it might be owed to the fact that I write the data into a file, but writting the file takes too much time and action 4.0 is carried out before the file was available, so it cannot send it out marking the whole task as aborted. Therefore, I was wondering if I can trigger an new event from this event whose duty will be to send the file once it was completely written. May that be done within the EEM?? Or is there another way of stopping the execution of the action4.0 until the action 3.0 was achieved?
event manager applet dataGather
event timer watchdog name dataGather time 900
action 1.0 cli command "enable"
action 2.0 cli command "term length 0"
action 3.0 cli command "show interface vlan 1 | append flash:vlan1I.txt"
action 4.0 cli command "copy flash:vlan1I.txt ftp://myFTPServer/vlan1I.txt "
action 5.0 cli command "delete flash:vlan1I.txt"
Thanks in advance,
Regards!
Solved! Go to Solution.
09-22-2013 10:31 AM
Hi Juan
Usually the 'copy' commands & 'delete' commands would ask for the confirmation from the users(try to execute them manually). Unless those confirmations are handled in the applet, it would not proceed the execution. That should be the issue with your applet(already indicated by Joe). There are two possible options.
1) Without changing your applet, you can configure the box for - not to promt for any confirmation (conf t ->
file prompt quiet). If you configure this CLI, the box will not ask for any confirmation from the users. So, it would execute the commads in your applet.
2) Other option which is suggested by Joe already. You should try the CLI commands manually and check for the additional queries / responses shown by the system for those CLIs.
For example, if you delete a file 'ttt.txt', it is asking for the additional confirmations.
0235-2900#delete flash0:ttt.txt
Delete filename [ttt.txt]?
Delete flash0:/ttt.txt? [confirm]
To handle these additional prompts in the applet, the expected string has to be matched by your CLI execution line(Otherwise, it would not complete the operation). For the above case, you can try
action 7.0 cli command "delete flash0:ttt.txt" pattern "Delete.*"
action 7.1 cli command "ttt.txt" pattern "Delete.*"
action 7.1 cli command ""
The action 7.1 cli command "" is like sending a 'enter' key in a keyboard.
09-21-2013 08:15 AM
I answer myself, I think that I might have found a solution, since EEM supports the command wait, so then I may modify my script like this, but I will have to test it.
event manager applet dataGather
event timer watchdog name dataGather time 900
action 1.0 cli command "enable"
action 2.0 cli command "term length 0"
action 3.0 cli command "show interface vlan 1 | append flash:vlan1I.txt"
action 4.0 wait 30
action 5.0 cli command "copy flash:vlan1I.txt ftp://myFTPServer/vlan1I.txt "
action 6.0 wait 30
action 7.0 cli command "delete flash:vlan1I.txt"
09-21-2013 01:35 PM
I don't think this will have the positive effect you think it will. I have a feeling that if you run these commands in sequence manually, you will find you get to a point where you are prompted for confirmation. That is likely what is preventing the applet from working properly. You can circumvent this with the "pattern" keyword after the command. For example:
action 5.0 cli command "copy flash:vlan1l.txt ftp://myFTPServer/vlan1l.txt" pattern "Address"
action 5.1 cli command "myFTPServer" pattern "filename"
action 5.2 cli command "vlan1l.txt"
09-22-2013 07:03 AM
Hi Joseph,
Do you mean that the confirmation are the "step" wchich avoid the execution of my applet, shouldn´t be also possible to configure my switch in "quiet mode", so it doesn´t prompt for confirmation?
On the other hand, if I use your commands, then on action 5.0 will the patern "Address" indicate to the prompt the address, or should I replace the "Address" with the current IP address of my ftp server? The same doubt pops up concerning to the action 5.1 with "filenanme", should I replace it by the actual filename to be sent? Finally, action 5.2 I cannot reach to understand it...
Edit: I think that it should be like this if I wanted to specify my server IP and file name, shouldn´t it?
action 5.0 cli command "copy flash:vlan1l.txt ftp://myFTPServer/vlan1l.txt"
action 5.1 cli command "myFTPServer" pattern "Address"
action 5.2 cli command "vlan1l.txt" pattern "filename"
Thanks in advance!
El mensaje fue editado por: Juan Cuesta
09-22-2013 10:31 AM
Hi Juan
Usually the 'copy' commands & 'delete' commands would ask for the confirmation from the users(try to execute them manually). Unless those confirmations are handled in the applet, it would not proceed the execution. That should be the issue with your applet(already indicated by Joe). There are two possible options.
1) Without changing your applet, you can configure the box for - not to promt for any confirmation (conf t ->
file prompt quiet). If you configure this CLI, the box will not ask for any confirmation from the users. So, it would execute the commads in your applet.
2) Other option which is suggested by Joe already. You should try the CLI commands manually and check for the additional queries / responses shown by the system for those CLIs.
For example, if you delete a file 'ttt.txt', it is asking for the additional confirmations.
0235-2900#delete flash0:ttt.txt
Delete filename [ttt.txt]?
Delete flash0:/ttt.txt? [confirm]
To handle these additional prompts in the applet, the expected string has to be matched by your CLI execution line(Otherwise, it would not complete the operation). For the above case, you can try
action 7.0 cli command "delete flash0:ttt.txt" pattern "Delete.*"
action 7.1 cli command "ttt.txt" pattern "Delete.*"
action 7.1 cli command ""
The action 7.1 cli command "" is like sending a 'enter' key in a keyboard.
09-23-2013 03:02 AM
Hi, You were right the problem is the querie for deleting the file, bu I am facing the issue that in order to emulate the 'enter'
the command action 7.1 cli command "" does not work, Could you tell me how should it be?
Thanks in advance!
09-23-2013 07:58 AM
For delete, there's an easier option that doesn't involve a config change:
delete /force FILENAME
09-22-2013 02:08 PM
No. What I said in my post was right. You would need to use "Address" and "filename" as-is as those are the strings you see in the prompt. As Anbu said, you can also use "file prompt quiet" to turn off most prompts. That will likely be sufficient for you in this case, but will require a config change.
08-30-2017 05:37 AM - edited 08-30-2017 08:08 AM
file
Router(config-applet)#action 5 file ?
close file close
delete file delete
gets file gets
open file open
puts file puts
read file read
write file write
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