InfoCenter Home > 6.6.0.2.2.3.2: Specifying lists in wscp commandsSome wscp options take Tcl lists as values (notably the -attribute option of create and modify operations). A Tcl list is an ordered collection of elements, where each element can be a string, a number, or another list. Lists can be delimited by either double quotation marks (" ") or braces ( { } ). The following example sets the variable x to a three-element list whose first element is the string "account", whose second element is "term", and whose third element is itself a list containing the two strings "maturity" and "date".set x {account term {maturity date}} In wscp, an attribute list is a list of attribute-value pairs (a Tcl list of lists). The following command modifies the PingInterval and PingTimeout attributes of an application server. The argument to the -attribute option is a list containing two elements. Both elements are themselves lists. wscp> ApplicationServer modify /Node:dev-pc/ApplicationServer:myServer/ -attribute {{PingInterval 120} {PingTimeout 240}} Note that Tcl parsers sometimes require a space between list items. An attribute list containing only one attribute-value pair must also be enclosed in a list. For example, in the following command, the attribute-value pair {PingTimeout 240} must be nested within braces: wscp> ApplicationServer modify /Node:dev-pc/ApplicationServer:myServer/ \ -attribute {{PingTimeout 240}} In addition to the modify operation, the show operation has an -attribute option that expects a Tcl list as its argument. If you specify only one attribute to be displayed, you can use either a string or a Tcl list. Tcl interprets both the string and the Tcl list of one element as equivalent--for example, the arguments JarFile and {JarFile} are equivalent. As in wscp, Tcl commands consist of one or more words separated by spaces. A Tcl word that contains spaces must be enclosed in either braces ({ }) or double quotation marks (" "). The use of braces and double quotation marks is similar. Both braces and double quotation marks can be placed around a word that contains embedded spaces. However, using braces and double quotation marks differs in two respects. First, unlike double quotation marks, braces can nest. Also, no substitutions occur inside braces, as they do inside double quotation marks. All characters between braces are passed as an argument to a command or procedure, without any special processing. Substitutions can occur later if the argument is evaluated again. Object names in wscp can contain spaces and therefore must be enclosed in either braces or double quotation marks. If object names are enclosed in braces, no evaluation takes place and everything in braces is passed to the command as an argument. If substitution must take place, for example, when the object name being passed as an argument contains a variable that must be expanded to form the name, then the object name must be enclosed in double quotation marks. The following example commands demonstrate the use of braces and double quotation marks in each case: # Braces used because object name contains spaces # Object name is passed to the command as an argument # and no substitution takes place wscp> ApplicationServer create {/Node:dev-pc/ApplicationServer:My Server/} wscp> ApplicationServer list {/Node:dev-pc/ApplicationServer:Default Server/} {/Node:dev-pc/ApplicationServer:Appl EJB Server/} {/Node:dev-pc/ApplicationServer:Model EJB Server/} {/Node:dev-pc/ApplicationServer:Model EJB Server2/} {/Node:dev-pc/ApplicationServer:Bean EJBServer/} {/Node:dev-pc/ApplicationServer:My Server/} # Double quotation marks used because substitution must take place # Assumes the NODE constant is defined as /Node:dev-pc/ wscp> ApplicationServer create "${NODE}ApplicationServer:Test Server/" wscp> ApplicationServer list {/Node:dev-pc/ApplicationServer:Default Server/} {/Node:dev-pc/ApplicationServer:Appl EJB Server/} {/Node:dev-pc/ApplicationServer:Model EJB Server/} {/Node:dev-pc/ApplicationServer:Model EJB Server2/} {/Node:dev-pc/ApplicationServer:Bean EJBServer/} {/Node:dev-pc/ApplicationServer:My Server/} {/Node:dev-pc/ApplicationServer:Test Server/} Lists are a special case of quoted strings, and Tcl quoting conventions can be nonintuitive. Be particularly careful when specifying strings that contain spaces. For example, the Environment attribute of application servers is a list of strings of the form name=value. If the value contains spaces, braces are required. The following command modifies the existing value of an Environment attribute: wscp> ApplicationServer modify /Node:dev-pc/ApplicationServer:Server1/ -attribute \ {{Environment {{VARIABLE=word1 word2}}}} The following command creates an application server and specifies two values for the Environment attribute. Note that the PATH environment variable does not require braces because it contains no spaces. wscp> ApplicationServer create /Node:dev-pc/ApplicationServer:Server2/ -attribute \ {{Environment {PATH=/myPath {OTHERVARIABLE=word1 word2}}}} The following commands display the Environment attributes of both servers in the above example: wscp> ApplicationServer show /Node:dev-pc/ApplicationServer:Server1/ -attribute Environment {Environment {{VARIABLE=word1 word2}}} wscp> ApplicationServer show /Node:dev-pc/ApplicationServer:Server2/ -attribute Environment {Environment {PATH=/myPath {OTHERVARIABLE=word1 word2}}} Note that when you modify an attribute, you are replacing the existing value with a new value. If you want to add to or replace part of an existing value (for example, change a path name), you must use a custom procedure. See Modifying an Environment attribute (modEnv procedure) for an example procedure named modEnv. The procedure can be used to modify the Environment attribute of one or more servers in a domain. It modifies one element of the list and retains the values of the other elements. Other attributes that take a list of strings as their arguments are the CommandLineArgs and SystemProperties attributes of application server objects. |
| ||
|