OSF DCE Administration Guide--Core Components

Using the DCE Control Program Command Language
dcecp> set a {a b {c d e} f}
ab{cde}f
dcecp> set b [llength $a]
4
dcecp> set c [expr $b-1]
3
dcecp> lindex $a $c
f
dcecp>
The DCE control program provides numerous commands for working with lists. You can
join lists together using the concat command. Use linsert to add elements to an existing
list. Extract a range of elements by using lrange, replace elements in a list with
lreplace, and sort list elements in alphabetical (dictionary) order by using lsort. The
DCE control program also includes an attrlist object (see attrlist(8dce) for use in
manipulating list elements.
Here’s an example that lists all child directories in a tree in alphabetic order. The _r
variable is a dcecp convenience variable that holds the output of the last command. In
this case, _r holds the list of directories returned by the directory list -simple command.
dcecp> directory list -simple /.:
hosts subsys cell-profile fs lan-profile planets_ch sec sec-v1
dcecp> lsort $_r
cell-profile fs hosts lan-profile planets_ch sec sec-v1 subsys
dcecp>
2.9 Controlling Scripts
The DCE control program provides several commands for controlling your script’s
execution. Commands such as if, while, for, foreach, and case execute parts of scripts
under various conditions. The break and continue commands can stop execution of part
or all of a command script.
2.9.1 Conditionalizing with if Statements
Sometimes, you’ll want part of your script to execute only under certain conditions. Use
an if statement to detect a condition and conditionally perform some operation. The
syntax for an if statement is
if test true_body else false_body
Let’s say you’re writing a script that searches through a list of attributes for a particular
attribute. An if statement could take particular actions depending on whether an attribute
124243 Tandem Computers Incorporated 2 17