OSF DCE Administration Guide--Core Components

OSF DCE Administration Guide—Core Components
Using lists to sort, find, and reuse information
Using arithmetic functions in commands and task scripts
Conditionalizing and controlling your script with if statements and loops
Executing scripts associated with character patterns by using the case command
Synthesizing commands by using eval
Importing operations with source
Creating new dcecp commands with proc
Using error and exception information
Handling strings
Working with files
Spawning subprocesses
2.2 Variable Substitution
Like other programming languages, dcecp provides shorthand ways to express and use
values. Variable substitution is one shorthand method that lets you represent a value—
say, the name of an object in a CDS directory—as a variable.
Use the set command to establish a value for a variable. For readability, a variable name
can consist of any combination of letters, numbers, and _ (underscore) characters. Use ""
(quotes) or \ (backslash) to include spaces in variable names (although this is not usually
recommended) or values. All of the following examples use valid variable names:
seta$i
set CDS_clearinghouse_name cambridge_ch
set DCE_user_1 "William Rosenberry"
The following example sets variable a to have a value of 7. The second use of the set a
command without a value causes dcecp to display the current value of the variable:
dcecp> set a 7
7
dcecp> set a
7
Once you have established a value for a variable using the dcecp set command, the
variable can be subsequently used elsewhere in your script or interactive command. The
DCE control program uses the $ (dollar sign) to trigger insertion of the current value into
the command word. A simple example is
dcecp> set a 7
7
dcecp> expr $a+2
2 2 Tandem Computers Incorporated 124243