OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
dcecp> set a 4
4
dcecp> set b [expr $a+2]
6
dcecp> set b
6
dcecp>
A more practical example might use command substitution for a command that returns a
long name or a list. Let’s recall an example we saw in Chapter 1. In this example, the
[group list temps] command returns a list to the foreach command that performs the
account modify operation on each element in the list. We’ll look more closely at the
foreach looping command later in this section.
dcecp> foreach i [group list users] {
> account modify $i -change {expdate 1995-12-31}}
dcecp>
Another practical use of command substitution is to set up a test condition for an if
statement. We show an example of this usage in Section 2.9.1.
2.4 Grouping Elements and Controlling Interpretation
Programming languages often use symbols such as braces, quotes, and parentheses to
operate on selected elements as a group rather than individually. Similarly, dcecp uses
"" (double quotes) and {} (braces) to group elements into structures called lists. A list is
a special way to group elements so that dcecp can correctly parse commands and other
data like return values. We’ll discuss lists further later on in the chapter.
The dcecp command elements are separated by whitespace: the space, tab, and newline
characters. The following dcecp command uses space characters to separate its three
elements:
dcecp> directory create /.:/subsys/comm_services
dcecp>
Use either the newline character or the ; (semicolon) to separate commands in a script.
The following two examples, which set and then use a variable, are equivalent:
dcecp> set a /.:/subsys/comm_services
/.:/subsys/comm_services
dcecp> directory create $a
dcecp>
dcecp> set a /.:/subsys/comm_services; directory create $a
dcecp>
2 4 Tandem Computers Incorporated 124243