OSF DCE Administration Guide--Core Components
DCE Control Program Introduction
you might want to add some entry to a CDS directory only if some other specified entry
already exists in CDS. The DCE control program makes this possible by utilizing Tcl’s
built-in commands that imitate elements commonly found in numerous programming and
shell languages.
The DCE control program contains many C-like constructs that control command
execution. Some examples are if statements for conditional execution, looping
commands such as while, for, and foreach used to repeat operations under various
conditions, a case command for testing values against various patterns, and proc for
writing your own customized commands.
The DCE control program also includes other syntactic elements such as "" (quotes), { }
(braces), [ ] (brackets), and \ (backslash), which it uses to group elements together and
for controlling interpretation of special characters.
Although many features are designed for use in scripts, you’ll probably find yourself
using some constructs and elements (particularly quotes, braces, brackets, and
backslashes) in interactive operations as well. You’ll need to decide when it makes
sense to perform operations interactively or to use a script. In general, complexity and
potential for reuse can help you decide.
Now let’s look at a couple of simple examples that illustrate some DCE control program
and Tcl basics. Some dcecp operations can be very straightforward like
dcecp> account modify N_Long -expdate 1996-06-30
This operation lets you change information in the DCE Security Service registry. Here,
we’re changing the account expiration date for the principal (N_Long) named in the
command line. While it’s relatively simple to execute this operation for one or two
principals, it’s more difficult to change the account expiration date for many principals.
Imagine that your organization employs six temporary workers and the project they’re
associated with has been extended for three months. Rather than execute the account
modify operation six times, you can use a dcecp foreach command to loop (repeat) an
action for each item of a list:
dcecp> foreach i {N_Long L_Jones P_Sawyer
> D_Witt M_Dougherty S_Preska} {
> account modify $i -expdate 1996-06-30 }
dcecp>
In the example, the foreach looping command has three arguments: a variable, a list,
and the body. The variable i substitutes sequentially for each item in the list (N_Long,
L_Jones, and so on). The foreach command executes the body (account modify $i
-expdate 1996-06-30)) for each item in the list. The $i variable in the body takes on the
value of each principal name in the list, in turn, until all items in the list have been used.
See Section 2.9.2 for more detailed information about looping commands.
This example illustrates several other important syntax rules. The DCE control program
uses { } (braces) to determine where command arguments, such as the script body, begin
and end. For example, the foreach command has three arguments: a variable name, a
list, and a script body. Normally, command arguments are separated by spaces. To
prevent dcecp from incorrectly interpreting the spaces between list elements as
argument separators, we use braces to enclose the list and disable special interpretation
124243 Tandem Computers Incorporated 1−7