OSF DCE Administration Guide--Core Components

Writing Scripts and dcecp Objects
By chaining operations together, you can create scripts that do more. 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."]
}
}
}
}
3.2 Formal Task Objects
Some DCE environments might have special administration needs that aren’t strictly
addressed by the standard DCE control program objects. While you could write and
distribute informal scripts to meet this administration need, you would likely need to
document their operation in some way. More importantly, though, a complicated
operation might require the use of numerous options to precisely control the script’s
behavior. Rather than invent your own mechanisms to provide help information and
handle complicated argument parsing operations, you could rely on the existing help
system and the parseargs facility utilized by other formal task objects supplied with
dcecp. This approach makes your script consistent with other dcecp objects.
Formal task objects build on the idea of the informal scripts presented previously with
some important additions:
124243 Tandem Computers Incorporated 33