OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
2.14.3 Reissuing Complex Errors
The proc command lets you create procedures or commands that perform very precise
operations. For instance, a user-written procedure called _dcp_get_servers that
retrieves and filters information about running servers could include nested commands or
procedures that perform various subtasks such as looping through server information
looking for certain strings. While use of nested commands or procedures lets you
develop comprehensive procedures or commands, they can also produce errors that are
difficult to pinpoint if errors aren’t passed along properly.
Complex scripts can use the error command to reissue errors that have been triggered by
some previously executing part of the script. The following script fragment simply prints
out a hard coded error message. This use also lets you custom tailor messages to
precisely explain error conditions.
set dts_cat_out [_dcp_dts_catalog]
if {[llength $dts_cat_out] == 0} {
error "Unable to find any DTS servers"
}
The next script fragment does more, using catch to store any error information returned
from the _dcp_create_group procedure in the msg variable. On failure (!= 0), the script
invokes a cleanup procedure that undoes whatever was done, and then prints out the
message stored in the msg variable.
if {[ catch {_dcp_create_group $group group_created} msg] !=0}{
_dcp_cleanup_user_create $element -principal
error $msg
}
This discussion has provided some fairly simple error handling techniques. Note,
though, that error handling can be complicated, especially in more complex situations.
We encourage you to read more about error handling in other publications that cover
more general use of Tcl.
2.15 Working with Files
The DCE control program has several commands for use in reading from and writing to
files. Files are useful for things like storing the output of dcecp operations for later
reference. Here are several useful examples of file manipulation:
You could run a server catalog operation across all of the hosts in a cell and store the
results from each host in a host-specific file. Later, you could compare the files to
produce a report of server configurations.
You could detect inactive accounts by running a dcecp script that shows the last time
each account was logged into, storing this information in a file for later evaluation.
2 32 Tandem Computers Incorporated 124243