cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
cancel
382
Views
2
Helpful
9
Replies

Cisco EEM scripts

surazb
Level 1
Level 1

Hi Experts,
Need your help one more time šŸ™‚

I am configuring EEM script for switches backup but i facing below errors

Configured command - 
action 25.0 cli command "copy running-config ftp://CISCOSWITCH:Passwd@192.168.10.10/SWITCH/IN/$h/$h-$t abc.txt"
Error -
%HA_EM-3-FMPD_UNKNOWN_ENV: fh_parse_var: could not find environment variable: h
Could you please help me here

Thanks a lot in advanced

9 Replies 9

Hello @surazb,

Do you have the command

cli command ā€œenableā€

in your script before the copy command?

can you share the script in order to better understand the issue?

Hope this helps. 
Liviu

Regards, LG
*** Please Rate All Helpful Responses ***

Here configured commands 

action 15.0 cli command "enable"
action 20.0 cli command "term len 0"
action 25.0 cli command "copy running-config ftp://CISCOSWITCH:Passwd@192.168.10.10/SWITCH/IN/$h/$h-$t abc.txt"

 

Do you have 

ftp username 

ftp password 

configured on the device?

Regards, LG
*** Please Rate All Helpful Responses ***

Yes, it is there and that is working fine 

The link provided by @Mark Elsen points to a possible cause for your issue.

If you have a support contract for your device, you can contact TAC for further investigation.

Hope this helps.

Liviu

Regards, LG
*** Please Rate All Helpful Responses ***

Mark Elsen
Hall of Fame
Hall of Fame

 

  - @surazb               FYI : https://bst.cisco.com/bugsearch/bug/CSCvg53802?rfs=qvred

  M.



-- Let everything happen to you  
       Beauty and terror
      Just keep going    
       No feeling is final
Reiner Maria Rilke (1899)

scottdanial1713
Level 1
Level 1

The error occurs because $h is not a predefined EEM environment variable. You must explicitly define it using event manager environment h <value> (for example, the hostname), or use a built-in variable like $_hostname. Replace $h with $_hostname (and $t with a supported time variable) to resolve the issue.

balaji.bandi
Hall of Fame
Hall of Fame

how is your whole EEM Script looks like and what device model is this ? -

Quick example :

event manager applet BACKUP_TO_FTP
event timer cron name DAILY_BACKUP cron-entry "0 0 * * *" ! Runs daily at midnight
action 1.0 info type routername
action 2.0 cli command "enable"
action 3.0 cli command "show clock"
action 4.0 regexp "([0-9:]+) ([A-Z]+) ([A-Za-z]+) ([0-9]+) ([0-9]+)" "$_cli_result" match time timezone month day year
action 5.0 cli command "copy running-config ftp://CISCOSWITCH:Passwd@192.168.10.10/SWITCH/IN/$_info_routername/$_info_routername-$year-$month-$day-$time.txt"

follow below detailed example to define variables :

https://www.balajibandi.com/?p=1554

BB

=====Preenayamo Vasudevam=====

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

How to Ask The Cisco Community for Help

scottdanial1713
Level 1
Level 1

The error occurs because EEM does not recognize $h and $t as valid environment variables. In EEM, you must use supported variables such as $_hostname or explicitly define variables using event manager environment before referencing them in the script. Once properly defined, the copy command should execute without errors.