Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the purpose of lines which start with double colon in TCL?

Tags:

tcl

Some of Cisco routers run operating system called IOS which has a built in TCL interpreter. I studied an example script for IOS TCL and it had following line at the beginning of the script:

::cisco::eem::event_register_timer cron name crontimer2 cron_entry $_cron_entry maxrun_sec 240

This $_cron_entry variable is an environment variable with value 0-59/2 0-23/1 * * 0-7, i.e. the line with double colon at the beginning can also be written like this:

::cisco::eem::event_register_timer cron name crontimer2 cron_entry 0-59/2 0-23/1 * * 0-7 maxrun_sec 240

Does the 0-59/2 0-23/1 * * 0-7 mean that execute maxrun_sec 240 every other minute in every hour? If yes, then what is the maxrun_sec as it is not defined anywhere in the script itself. How to understand the ::cisco::eem::event_register_timer cron name crontimer2 cron_entry part?

like image 758
Martin Avatar asked Feb 01 '26 23:02

Martin


1 Answers

Those are command calls where those commands are given in fully-qualified form. The double-colon (::) is a namespace separator, and by analogy with the filesystem, if the name starts with the separator, it's resolved with respect to the global namespace.

For example, the global set command can equivalently be called as ::set. It will work identically. This is useful if you're in another namespace that defines its own set command:

namespace eval example {
    proc set {} {
        for {::set x 1} {$x <= 5} {incr i} {
            puts "This is example::set with x = $x"
        }
    }

    set
}

Now, in your case the command is called ::cisco::eem::event_register_timer in fully qualified form. That should be read as the event_register_timer command in the eem namespace that itself is in the cisco namespace, which in turn is a direct child of the global namespace. It's just like with filenames, except it's a multi-character separator.

(As for what it does… check the Cisco documentation. It's not a standard Tcl command…)

like image 183
Donal Fellows Avatar answered Feb 03 '26 11:02

Donal Fellows