Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements
Webcast-Catalyst9k
New Member

import tcllib for Hash(sha1) on IOS

Hi,

I know that i need to download "tcllib" from  http://www.tcl.tk/software/tcllib/ but i don't know how to import them to the TCL script? 

Where should i locate them ?

Thanks.

 

 

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Cisco Employee

  put this into a file on

 

 

put this into a file on flash called external.tcl

####START####

package require sha256
proc send_syslog { msg } {
        set syslog [open "syslog: " w+]
        set example [sha2::sha256 "Tcl does SHA256"]
        puts $syslog "$msg $example "
        close $syslog
}
send_syslog "MY HASH = "

####END#####

In IOS execute:

C819-4G(config)#scripting tcl init flash:sha256.tcl
C819-4G(config)#exit
C819-4G#tclsh flash:external.tcl

 

Cisco Employee

You also need to generate a

You also need to generate a autoload tclIndex file to bring in the module.  This can be done with the auto_mkindex Tcl command on a host.  See tmpsys:/lib/tcl/tclIndex as an example.  Once this file has been generated for the SHA256 module, you need to add it to your user library directory, and then unconfigure and reconfigure the command to specify the user library directory.  Then you will be able to import the sha256 module.

11 REPLIES
Cisco Employee

Transfer file "sha256.tcl" to

Transfer file "sha256.tcl" to flash and execute these commands.

C819-4G(config)#scripting tcl init flash:sha256.tcl
C819-4G(config)#exit
C819-4G#tclsh
C819-4G(tcl)#package require sha256
1.0.3
C819-4G(tcl)#sha2::sha256 "Tcl does SHA256"
0b91043ee484abd83c3e4b08d6034d71b937026379f0f59bda6e625e6e214789
C819-4G(tcl)#

 

New Member

Thank you for the answer.But

Thank you for the answer.

But when i write the code in other file located on flash, its not working: (external.tcl):

proc init {} {

package require sha256

set example sha2::sha256 "Tcl does SHA256" 

action_syslog priority info msg "$example"

}

 

Cisco Employee

  put this into a file on

 

 

put this into a file on flash called external.tcl

####START####

package require sha256
proc send_syslog { msg } {
        set syslog [open "syslog: " w+]
        set example [sha2::sha256 "Tcl does SHA256"]
        puts $syslog "$msg $example "
        close $syslog
}
send_syslog "MY HASH = "

####END#####

In IOS execute:

C819-4G(config)#scripting tcl init flash:sha256.tcl
C819-4G(config)#exit
C819-4G#tclsh flash:external.tcl

 

New Member

I get "Can't find package

I get "Can't find package sha256" error, when i used:

::cisco::eem::event_register_track $track state up maxrun 1000

The external.tcl run automatically with ip sla trigger.

Do you know why?

New Member

someone?

someone?

New Member

::cisco::eem::event_register

 

### START ####

::cisco::eem::event_register_track $track state up maxrun 1000

namespace import ::cisco::eem::*

namespace import ::cisco::lib::*

package require sha256

proc send_syslog { msg } {

   set syslog [open "syslog: " w+]

   set example [sha2::sha256 "Tcl does SHA256"]

    puts $syslog "$msg $example "

    close $syslog

}

send_syslog "MY HASH = "

#### END ####

Error:

"invoked from within source flash:/sha256.tcl (package ifneeded scritpt)..."

someone?

Cisco Employee

I can not get this working in

I can not get this working in a EEM tcl file either (still investigating).   Another way that does work is to launch a normal tcl script from an EEM applet.

 

event manager applet SHA
 event none
 action 010 cli command "enable"
 action 020 cli command "tclsh flash:external.tcl"

external.tcl looks like this.

package require sha256
proc send_syslog { msg } {
        set syslog [open "syslog: " w+]
        set example [sha2::sha256 "Tcl does SHA256"]
        puts $syslog "$msg $example "
        close $syslog
}
send_syslog "MY HASH = "


 

New Member

Thanks for the responseBut i

Thanks for the response

But i need also import  "::cisco::eem::*" and "::cisco::lib::*"

There is another option it will work ?

 

Cisco Employee

"::cisco::eem::*" and ":

"::cisco::eem::*" and "::cisco::lib::*" should not be included in a raw TCL script.

New Member

But I need to use them in the

But I need to use them in the TCL script

I want to combine ::cisco::eem::*" and "::cisco::lib:: options with SHA256 options. It is possible?

Cisco Employee

You also need to generate a

You also need to generate a autoload tclIndex file to bring in the module.  This can be done with the auto_mkindex Tcl command on a host.  See tmpsys:/lib/tcl/tclIndex as an example.  Once this file has been generated for the SHA256 module, you need to add it to your user library directory, and then unconfigure and reconfigure the command to specify the user library directory.  Then you will be able to import the sha256 module.

352
Views
0
Helpful
11
Replies
CreatePlease to create content