Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. If you'd prefer to explore, try our test area to get started. And see here for current known issues.

New Member

How to run tcl script in other tcl script

Hi all!

I need to make a script ping vrf IP and modify config cisco

Operates in two modes

1) manual - system administrator configure

2) automatic - script

If the system administrator has changed the config cisco, the script does not have to make changes.

The script creates the file and if there is "Tcl_SB_Status = 0", the script will not make changes.

File:

Router#dir

Directory of sup-bootdisk:/

   49  -rw-         152  Aug 16 2013 06:48:32 +00:00  tcl_status.tcl

...

256548864 bytes total (186482688 bytes free)

Router#more sup-bootdisk:/tcl_status.tcl

proc SB_Status {} {

                global Tcl_SB_Status

                global SB_ospf_red

                global SB_bgp_red

                set Tcl_SB_Status 0

                set SB_ospf_red ""

                set SB_bgp_red ""

                }

Run tcl script on cisco, but get an error:

Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: script error

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: "source $Tcl_status"

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: "$slave eval $Contents"

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     (procedure "eval_script" line 7)

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: "eval_script slave $scriptname"

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: "if {$security_level == 1} {       #untrusted script

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:      interp create -safe slave

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:      interp share {} stdin slave

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:      interp share {} stdout slave

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: ..."

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: Tcl policy execute failed:

*Aug 16 06:43:32.609: %HA_EM-6-LOG: ping_vrf.tcl: script error

debug (Router#debug event manager all):

Router#

*Aug 16 06:46:32.201: fh_fd_timer_process_async

*Aug 16 06:46:32.201: fh_fd_timer_event_expire: re=0x4B04887C

*Aug 16 06:46:32.201: fh_send_server_sig_hndlr: received a pulse from timer on node5/2 with fdid: 83886095

*Aug 16 06:46:32.201: fh_send_timer_fd_msg: msg_type=64

*Aug 16 06:46:32.201: fh_send_timer_fd_msg: sval=0

*Aug 16 06:46:32.201: fh_send_server_sig_hndlr: received FH_MSG_EVENT_PUBLISH

*Aug 16 06:46:32.201: EEM: server processes multi events: timewin=1, sync_flag=0, ec_index=0, cmp_occ=1

*Aug 16 06:46:32.201: EEM: ctx=21:(21,1,1)

*Aug 16 06:46:32.201: EEM: server processes multi events: corr_res=1, cur_tcnt=1, cmp_tcnt=1

*Aug 16 06:46:32.201: fh_schedule_policy: prev_epc=0x0; epc=0x4B127434

*Aug 16 06:46:32.201: EEM server schedules scripts

*Aug 16 06:46:32.201: EEM server schedules one event: policy_type=script epc=4B127434.

*Aug 16 06:46:32.201: EEM: server schedules a policy: policyname=tmpsys:/eem_policy/ping_vrf.tcl

*Aug 16 06:46:32.201: spawn script tmpsys:/eem_policy/ping_vrf.tcl

*Aug 16 06:46:32.201: EEM policy tmpsys:/eem_policy/ping_vrf.tcl has been scheduled to run

*Aug 16 06:46:32.201: fh_spawn: -FMRUN -FMSAFE tmpsys:/lib/tcl/base.tcl tmpsys:/eem_policy/ping_vrf.tcl

*Aug 16 06:46:32.201: fh_tcl_spawn: argc=5, argstr=-FMRUN, stdin=null:/ping_vrf.tcl, stdout=syslog:/info/noscan/ping_vrf.tcl,stderr=syslog:/err/noscan/ping_vrf.tcl, priority=4

*Aug 16 06:46:32.205: pid for spawned process is 71. fdid: 83886095 sn: 68 jobid: 69

*Aug 16 06:46:32.205: fh_tcl_esi_open: fd=1

*Aug 16 06:46:32.205: fh_tcl_esi_open: fd=2

*Aug 16 06:46:32.205: fh_tcl_get_mode: mode = 1, StartupScript = tmpsys:/lib/tcl/base.tcl, RealScript = tmpsys:/eem_policy/ping_vrf.tcl

*Aug 16 06:46:32.205: fh_set_tclpath_global: tcl_library is set to tmpsys:/lib/tcl

*Aug 16 06:46:32.205: fh_set_tclpath_global: auto_path is set to tmpsys:/eem_lib_user tmpsys:/eem_lib_system

*Aug 16 06:46:32.221: fh_io_msg: received FH_MSG_API_INIT; jobid=105, processid=71, client=95, job name=EEM TCL Proc

*Aug 16 06:46:32.221: fh_register_evreg_cmds: tctx=4B1007D8, dummy=1

*Aug 16 06:46:32.221: fh_tcl_compile_policy: evaluating policy: startup_scriptname=tmpsys:/lib/tcl/base.tcl, real_scriptname=tmpsys:/eem_policy/ping_vrf.tcl

*Aug 16 06:46:32.225: fh_tcl_slave_interp_init: interp=4B0758E0, tctx=4B1007D8, fh_mode=1, real=tmpsys:/eem_policy/ping_vrf.tcl, curr=ping_vrf.tcl

*Aug 16 06:46:32.233: fh_register_evreg_cmds: tctx=4B1007D8, dummy=1

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: script error

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: "source $Tcl_status"

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: "$slave eval $Contents"

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     (procedure "eval_script" line 7)

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: "eval_script slave $scriptname"

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     invoked from within

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: "if {$security_level == 1} {       #untrusted script

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:      interp create -safe slave

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:      interp share {} stdin slave

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:      interp share {} stdout slave

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: ..."

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl:     (file "tmpsys:/lib/tcl/base.tcl" line 50)

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: Tcl policy execute failed:

*Aug 16 06:46:32.613: %HA_EM-6-LOG: ping_vrf.tcl: script error

*Aug 16 06:46:32.613: fh_server: fh_io_msg: received msg FH_MSG_API_CLOSE from client 95 pclient 95

*Aug 16 06:46:32.613: fh_io_msg: received FH_MSG_API_CLOSE client=95

*Aug 16 06:46:32.617: fh_tcl_esi_close: fd=1

*Aug 16 06:46:32.621: fh_tcl_esi_close: fd=2

*Aug 16 06:46:32.621: fh_tcl_assoc_data_delproc: freeing tctx=0x4B1007D8

*Aug 16 06:46:32.649: cli_history_entry_add: free_hist_list size=0, hist_list size=7

*Aug 16 06:46:32.649: check_eem_cli_policy_handler: command_string=debug event manager all

*Aug 16 06:46:32.649: check_eem_cli_policy_handler: num_matches = 0, response_code = 1

*Aug 16 06:46:32.649: received SIGCHLD pulse from child death pid=71

*Aug 16 06:46:32.649: received pulse from child death code=2; epc=0x4B127434

*Aug 16 06:46:32.649: EEM policy ping_vrf.tcl has completed with abnormal exit status of 0x1 exec_status=2 event_completion=0

*Aug 16 06:46:32.649: EEM fms_remote_chkpt_add_event_hist(), data_len = 2980, buf_size = 2992

*Aug 16 06:46:32.649: EEM: server decrements in use thread: jobid=69 rule id=1 in use thread=0.

*Aug 16 06:46:32.649: fh_schedule_policy: prev_epc=0x4B127434; epc=0x0

*Aug 16 06:46:32.649: EEM server schedules scripts

*Aug 16 06:46:32.649: EEM server schedules sync same source events:fdid=83886095; sn=68.

-------------------------------------------------------------------------------------------

Router#sh ver

Cisco IOS Software, c7600s3223_rp Software (c7600s3223_rp-ADVIPSERVICESK9-M), Version 12.2(33)SRE2, RELEASE SOFTWARE (fc1)

Can anyone help?

2 REPLIES
Silver

How to run tcl script in other tcl script

You might have better luck moving this post to the EEM forum:

https://supportforums.cisco.com/community/netpro/network-infrastructure/eem?view=discussions

New Member

How to run tcl script in other tcl script

I realized what my mistakу...

https://supportforums.cisco.com/docs/DOC-12757#Introduction

"Once this command is configured, EEM copies all of the .tcl files found in the defined device and directory to a virtual file system for later use.  When an EEM Tcl policy is triggered, the user libraries are made available to the EEM Tcl policy by use of the Tcl sourcecommand, for example:

source "user_library.tcl"

NOTE: If you make any changes to this directory (i.e. add new library files), you must unconfigure and reconfigure the user library directory before those library files will be available to your EEM policies."


thank you all...

683
Views
0
Helpful
2
Replies