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

TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

What version of code is this switch running?

Community Member

Re: TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

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
Community Member

Re: TCL or EEM Script needed

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

4507#tclsh ???? then what?

thank you

CCIE 18676
Cisco Employee

Re: TCL or EEM Script needed

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.

Community Member

Re: TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

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.

Community Member

Re: TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

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
Community Member

Re: TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

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?

Community Member

Re: TCL or EEM Script needed

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
Cisco Employee

Re: TCL or EEM Script needed

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).

1073
Views
0
Helpful
13
Replies
CreatePlease to create content