iTP Secure WebServer System Administrator's Guide (iTPWebSvr 6.0+)

Tool Command Language (Tcl) Basics
iTP Secure WebServer System Administrator’s Guide—523346-002
E-6
Script Commands
if expression if_true [else if_false]
The if command provides conditional execution for controlling the flow of
execution in a Tcl script. If expression evaluates to a nonzero result, the
if_true statement is executed; otherwise, the if_false statement (if specified)
is executed. For example, the following command sets the variable x to zero if its
value was previously negative:
if {$x < 0} { set x 0 }
switch value { pattern command pattern command ...}
The switch command provides conditional execution on the basis of a pattern
matching a specified value. The switch command compares value against each
listed pattern and executes the command associated with the first match. If one
of the patterns is default, the command associated with this pattern will be
executed if no match occurs. For example:
switch $x {
*.company.com { set flag 1 }
*.widgets.com { set flag 2 }
default { set flag 3 }
}
In this example, if the value of x matches *.company.com, flag is set to 1. If x
matches *.widgets.com, flag is set to 2. If no match occurs, flag is set to 3.
string match pattern string
The string match command provides string matching. If pattern matches
string, the command returns 1 (indicating true); otherwise, it returns 0.
info exists variable
The info exists command determines if a variable or array element exists. If
variable exists, the command returns 1 (indicating true); otherwise, it returns 0.
For example, the following command will return 1 if the array element
HEADER(item) exists:
info exists HEADER(item)
&& Logical AND. Produces a 1 result if both operands are nonzero; 0 otherwise.
Valid only for numeric operands (integers or floating-point).
|| Logical OR. Produces a 0 result if both operands are zero; 1 otherwise. Valid
only for numeric operands (integers or floating-point).
x?y:z If-then-else, as in C. If x evaluates to nonzero, the result is the value of y.
Otherwise, the result is the value of z. The x operand must have a numeric
value.
Table E-1. Tcl Expression Operators (page 2 of 2)
Operator Description