cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1741
Views
0
Helpful
13
Replies

TCL or EEM Script needed

Marcin Zgola
Level 4
Level 4

Guys, I am not familiar with TCL or EEM yet, but i need a script that will shut down port 7/43 on my 4507.

Basically i have an application that can log in via SSH to my core, and only execute one command from enable mode.

I need that command to shut down the port 7/43

can you help?

thanks

CCIE 18676
13 Replies 13

Joe Clarke
Cisco Employee
Cisco Employee

What version of code is this switch running?

I am running 12.2(53)SG1 on my 4507. It support EEM and tcl.

let me know if you need anything more.

CCIE 18676

You could use this simple tclsh script:

ios_config "interface 7/43" "shut" "end"

Call this script whatever you want (e.g. shut_int.tcl).  Then execute with:

tclsh flash:/shut_int.tcl

how do i do that?? sorry i am totally new to that.

4507#tclsh ???? then what?

thank you

CCIE 18676

As I said, you take the contents of the script (the one ios_config line), and stick that line in a file.  That file can be called whatever you want (I chose "shut_int.tcl").  You then copy that file to the switch's flash.  You then execute it with the tclsh line I provided:

Switch#tclsh flash:/shut_int.tcl

That will shutdown the interface desired.

Ok here is what i have

i created a file with

ios_config "interface g7/43" "shut" "end"

then i copied to bootflash

after

tclsh bootflash:/portshut.tcl

nothing happens, i even tried

ios_config "config t" "interface g7/43" "shut" "end"

CCIE 18676

You must use the line I provided.  Your line will not work.  You must also make sure you are enabled at privilege level 15.  Beyond that, you should see nothing displayed when the script runs.  It should just shutdown interface gi7/43.  That is, if you now do a show run, you should see the "shutdown" command under interface GigabitEthernet7/43.

i do have that, and nothing

the only difference is on your script "interface 7/43" where on mine is g7/43

is it possible to debug this script to make sure everything works properly?

CCIE 18676

Yes, you'd need gi7/43 to make it work.  No, tclsh scripts cannot be debugged.  Try using an EEM applet instead:

event manager applet shutport

event none

action 1.0 cli command "enable"

action 2.0 cli command "config t"

action 3.0 cli command "int gi7/43"

action 4.0 cli command "shut"

action 5.0 cli command "end"

Then run it with:

Switch#event manager run shutport

this is wierd i just tested on the router i have and it works

stupid 4507 wont take both scripts

maybe IOS bug????

CCIE 18676

Do you have command authorization enabled on the switch?  If you enable "debug event manager action cli" on the switch, and re-run the policy, what output do you get?

this is a problem for event manager i think

i am running tacacs and we do not use enable passwords.

but your tcl script works on my router but not on the 4507.

i got enough of information to troubleshot the problem.

thank you so much for your help.

let me spend some time to see what i can do , and i will write back if i need any more help.

thanks again

CCIE 18676

No, EEM requires NO passwords.  If you are using AAA command authorization though, you will need to configure the following:

event manager session cli username USER

Where USER is a username authorized to run the CLI commands in the EEM policy (e.g. your username).

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community:

Innovations in Cisco Full Stack Observability - A new webinar from Cisco