PreviousNext

Informal Administration Scripts

Informal administration scripts let administrators store multiple operations in a file and replay them whenever necessary. Informal scripts are useful for operations that take only one or two arguments or that just perform simple tasks. Furthermore, the script's precise behavior and output can be custom-tailored to the needs of whoever is writing it. While informal scripts can be shared among administrators in a cell, they are typically included just in the author's .dcecprc file.

Scripts generally consist of one or more procedures created with the proc command. This lets you invoke the scripted operation by simply typing the procedure's name at the dcecp prompt.

The following simple script prints information about who you are in terms of your current cell and login identity.

# Show your current login name and your current cell name.
proc _dcp_whoami {} {
global _c _u
puts stdout "You are '$_u' logged into '$_c'."
}

This script can be included in your .dcecprc file either directly or by using the source command and keeping the actual script in an external file. The second method lets other administrators include your same script by simply pointing to it with source commands in their .dcecprc files. This method also keeps your .dcecprc file uncluttered making it easier for others to understand what is going on. Alternatively, you can place the script or a pointer in the init.dcecp file. changes to this file are available to all users on a host. For more information about the init.dcecp file and the .dcecprc file, see Customizing dcecp Sessions. An example of the source command in a .dcecprc file is:

source /usr/users/wardr/dcecp/local_lib.dcp

The .dcp filename extension is a convention for naming files used by the DCE control program. Another convention precedes procedure names with _dcp as in _dcp_whoami. Many dcecp procedures adhere to this convention to distinguish their names from user-created procedures which do not need to use this convention. If you find procedure names like _dcp_whoami hard to remember or type, you can rename them. For instance you could rename the procedure to whoami using the rename command in the .dcecprc file:

rename _dcp_whoami whoami

Restart the dcecp program to pick up any changes. Now you can type whoami at the DCE control program prompt:

dcecp> whoami
You are 'cell_admin' logged into '/.../my_cell.goodco.com'.
dcecp>

You can create scripts that do more by chaining operations together. For example the following script lists all the hosts in a DCE cell. Then it checks whether each host has an object entry in CDS for a dts entity (this would indicate that a DTS server is available on the host). For each host with an object entry for a dts-entity, the script does a clock show operation which returns the time on that host. The script prints the information on the display formatting it for readability and continues looping through all the hosts in the cell until all host entries have been checked.

Make the _dcp_show_clocks procedure available to your dcecp session in the same way as the simpler script described previously.

# 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."]

}

}

}

}