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

Sending generated file to tftp via EEM

Irbis_Grey
Level 1
Level 1

Hello colleagues

 

Here is the part of the script, that i use:

 

event manager applet test777 authorization bypass
event cli pattern "testme" enter
action 1 info type routername
action 10 cli command "enable"
action 11 cli command "sh clock"
action 12 regexp "([0-9]+).([0-9]+).([0-9]+).*" "$_cli_result" match hour minute sec
action 13 set result "diag_$_info_routername-$hour:$minute:$sec"
action 14 set filename "$result.txt"
action 50 cli command "show interfaces po1 | append bootflash:$filename"
action 110 cli command "more bootflash:$filename | redirect tftp://xx.xx.xx.xx/$filename"
action 120 file delete bootflash:$filename
action 130 cli command "end"

 

The problem occurs in the step 110, comes an error:

022395: Feb 25 13:59:04: %HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: filename
022396: Feb 25 13:59:04: %HA_EM-3-FMPD_ERROR: Error executing applet test777 statement 110

 

Please advice, how i can transfer newly generated file to tftp by the script.

1 Accepted Solution

Accepted Solutions

Irbis_Grey
Level 1
Level 1

Problem solved with the help of patterns. For someone, who face the same problem - here is the solution:

 

action 80 cli command "delete bootflash:$filename" pattern "Delete.*"
action 80.1 cli command "bootflash:$filename" pattern "Delete.*"
action 80.2 cli command ""

 

 

View solution in original post

4 Replies 4

balaji.bandi
Hall of Fame
Hall of Fame

action 14 set filename "$result.txt"  

 

you need to use below format

 

action XX  set filename "$_string_result.txt"
action XX puts "$filename"

BB

***** Rate All Helpful Responses *****

How to Ask The Cisco Community for Help

Thank you

 

But how would that help with transfering file to tftp? The error is on the step 110.

Irbis_Grey
Level 1
Level 1

ADDITION:

 

There was a problem in order, 110 executed before 12. Now the file transfers correctly, but there is error in deleting. 

Irbis_Grey
Level 1
Level 1

Problem solved with the help of patterns. For someone, who face the same problem - here is the solution:

 

action 80 cli command "delete bootflash:$filename" pattern "Delete.*"
action 80.1 cli command "bootflash:$filename" pattern "Delete.*"
action 80.2 cli command ""