OSF DCE Administration Guide--Core Components
Using the DCE Control Program Command Language
You can perform pattern-matching operations in any of several ways. Invoke ‘‘glob’’
style pattern matching with the string match command. This mimics the glob pattern
matching capabilities available in csh, returning 1 for a match and 0 for no match. More
flexible regular expression pattern matching (like that found in egrep) can be performed
using regexp command. You can extend this operation to perform regular expression
substitution by using the regsub command.
The following example illustrates the use of the regsub command. The first argument
specifies the search pattern. The second argument is the string to search. The third
argument specifies the replacement pattern. The last argument is a variable into which
regsub places the new string. The command returns 0 if no substitution occurs and 1 if
substitution does occur.
dcecp> regsub brown "The quick brown fox" blue color
1
dcecp> puts $color
The quick blue fox
2.14 Dealing with Errors and Exceptions
The dcecp interpreter includes error facilities that return error information when
something goes wrong with a dcecp script. Error information tells users what went
wrong so that they can avoid making the same mistake in the future. Many things can
cause dcecp errors. For instance, a command might not receive the correct number of
arguments, a command might have a typographic error of some kind, or the object of an
operation (such as a CDS directory) might be unavailable for some reason.
Here, we discuss three ways of dealing with errors and exceptions:
• Using global error information variables
• Catching exceptions
• Reissuing complex errors
2.14.1 UsingGlobal Error Information Variables
When dcecp encounters an error it prints a descriptive message, such as:
Error: wrong # args: should be "set varName ?newValue?"
In some cases, error messages may be insufficient for determining exactly where a
problem occurred. So dcecp stores additional error information in a global variable
called errorInfo. Your script can access and print this information to help you find the
error. Generally, it traces the commands that were executing when the error occurred.
124243 Tandem Computers Incorporated 2− 29