[ Previous ] [ Contents ] [ Index ] [ Next ]

Tcl-only Modules

As described in the "Private and Shared Libraries" section, you can define a private and shared Tcl directory for each virtual server. However, none of the subdirectories under either the private or shared Tcl directories will be initialized unless you load a corresponding module. For example, if the ServerA server has a shared Tcl directory defined as /home/mydir/tcl/a, and the nsdb and perm modules are loaded, then the following directories will be initialized as server start-up:

    /home/mydir/tcl/a
    /home/mydir/tcl/a/nsdb
    /home/mydir/tcl/a/perm

If you want another directory under /home/tcl/a that contains Tcl scripts to be initialized also, you must load a Tcl-only module for it into the server using the "Tcl" keyword.

Configuration for Tcl-only Modules

To load a Tcl-only module using the Setup Server, follow the Virtual Servers link from the Setup Server page, click on the arrow next to a virtual server, and press the Add Module button to add a module to the virtual server. On the Add Module page, choose "Arbitrary Module", and type "mytcl" and "Tcl" in the fields.

Or, add the following line to your configuration file:

    [ns/server/servername/modules]
    mytcl = Tcl

Then, at server start-up, the /home/mydir/tcl/a/mytcl directory will be initialized too. You can load any number of Tcl-only modules into a virtual server to have the Tcl scripts in the corresponding directories initialized.

For Tcl-only modules, no C module file is loaded. Only the corresponding Tcl directories are initialized.

Example of Tcl Initialization with Tcl-only Modules

This example shows demonstrates the order in which Tcl scripts are initialized at startup time for a server. The Library and SharedLibrary parameters are not set, so the private library for S1 defaults to /servers/S1/modules/tcl and the shared library for S1 defaults to /modules/tcl. A Tcl-only module called M1 is loaded for S1 as follows:

    [ns/server/S1/modules]
    M1=Tcl

The private library for server S1 (/servers/S1/modules/tcl) contains these files:

    abc.tcl

The shared library for server S1 (/modules/tcl) contains these files:

    abc.tcl
    init.tcl
    share1.tcl
    share2.tcl

The private library for module M1 (/servers/S1/modules/tcl/M1) contains these files:

    init.tcl
    priv.tcl
    script1.tcl

The shared library for module M1 (/modules/tcl/M1) contains these files:

    glob.tcl
    script1.tcl
    script2.tcl

The Tcl files will be sourced in this order:

    /modules/tcl/init.tcl
    /modules/tcl/share1.tcl
    /modules/tcl/share2.tcl
    /servers/S1/module/tcl/abc.tcl
    /modules/tcl/M1/glob.tcl
    /modules/tcl/M1/script2.tcl
    /servers/S1/module/tcl/M1/init.tcl
    /servers/S1/module/tcl/M1/priv.tcl
    /servers/S1/module/tcl/M1/script1.tcl

Note that the abc.tcl and script1.tcl files were each in both a private and shared directory, but they were sourced only from the private directories.

Top of Page

[ Previous ] [ Contents ] [ Index ] [ Next ]
Copyright © 1996 America Online, Inc.