Adding Scripts to dcecp Sessions
Once you have written a script, you can make it available to one person or to everyone who is logged into the host by modifying one or more of the following files invoked when
dcecp initializes:
[info library]/init.tcl This file is read first and contains standard Tcl initialization commands for the host. This affects all instances of dcecp running on a host. The
file contains definitions for the Tcl unknown command and the auto_load facility used for initializing all of the dcecp objects. Administrators should avoid adding
dcecp customizations to this file.
dcelocal/init.dcecp This file contains dcecp-specific startup information for the host. This affects all instances of dcecp running on a host. The
dcecp scripts implementing operations and tasks are stored in the dcelocal/dcecp directory. Add customizations in the form of procedures to this file to make them
available to all dcecp users on the host.
$HOME/.dcecprc This optional file stores user customizations which affect individual dcecp users (the owners of the .dcecprc files). Each DCE user can
maintain a .dcecprc file and store their private procedures or alias names for operations. Modified .dcecprc files allow flexible administration in environments with multiple
administrators. For example, different .dcecprc files for each administrator could use dcecp source commands to call in specific commands and task scripts that are
tailored to particular areas of administration.
The rest of this topic illustrates a simple task script and shows one way to make the script available for personal use. Our example begins with the control program's existing clock object
which shows the current time. However, the time is simply a DTS timestamp from the clock on the local host as in:
dcecp> clock show 1994-10-03-10:22:59.991-04:00I----- dcecp>
Let us say you create a procedure that gets a timestamp from a DTS server but also displays the name of the DTS server with the time as in the following example which invokes a user-created procedure
called show_clock.
dcecp> show_clock Time on mars is 1994-09-30-15:03:43.97904:00I----- dcecp>
You can make this procedure available to one user by including the procedure in the user's .dcecprc file. The following example .dcecprc includes user customizations consisting of
the _dcp_show_clocks procedure and an alias that lets you invoke the procedure using the simpler show_clocks command name. Another procedure called _dcp_whoami shows the
current login identity information. Note the order of operations in the .dcecprc file. Procedures are defined at the beginning of the file. Renaming and invoking the procedures must occur
after the procedures are defined.
## ## Start up commands$ ## # A simple command to rerun .dcecprc after modifications proc .d {} {source $HOME/.dcecprc}
# Show your current login name and your current cell name. proc _dcp_whoami {} { global _c _u return "You are '$_u' logged into '$_c'."
} # Show the time on all of the dts servers running in your cell. proc _dcp_show_clocks {} { set x [directory list /.:/hosts]
foreach n $x { if {[catch {object show $n/dts-entity}] == 0} { set index [string last "/" $n] set y
[string range $n [incr index] end] if {[catch {clock show $n/dts-entity} msg] == 0} { set i [expr 20 - [string length $y]]
puts [format "Time on $y is %${i}s %s" " " \ [clock show $n/dts-entity]] } else {
set i [expr 20 - [string length $y]] puts [format "Time on $y is %${i}s %s" " " \ "Server not responding."]
} } } } # Give some procs usable names rename _dcp_whoami whoami rename _dcp_show_clocks
show_clocks # If I am authorized, say so if {$_u != ""} { whoami }
The rename command near the end of the file lets you invoke the _dcp_show_clocks and _dcp_whoami procedures using the easier command names show_clocks and
whoami.
When you start the dcecp program, the last part of this file invokes the _dcp_whoami procedure if you are logged into DCE. If the _u convenience variable is set, the
_dcp_whoami procedure prints your current login identity as:
% dcecp You are 'principal_name' logged into 'cell_name'. dcecp>
|