Scripting Commands

You can use advanced scripting constructs to combine multiple commands and write complex scripts.

The Shell commands support the following advanced constructs for scripting:

  • Arrays
  • Running multiple commands at once
  • Pipes
  • Closures
  • Json ComplexType

Arrays

Arrays can be passed as arguments to some commands. For example, the echo command takes an array of arguments passed to it and displays them at the command prompt.
echo [ 'a' 'b' 'c']
[a,b,c]
Note: In the web UI, use commas as separators. For example, ['a', 'b', 'c']. In the shell UI, do not use commas as separators. For example, ['a' 'b' 'c'] .

Running Multiple Commands at Once

Multiple commands can be run by separating them with a ';' (semicolon).
admin@localhost:/> cd /TEA;ls
members
agents
users
groups
roles
realms
machines
solutions

Pipes

Output of one command can be piped to the input of another command using a '|'.
admin@localhost:> ls TEA/members/Roles | grep a
TEA_ADMIN
Tomcat Admin
Tomcat User

Closures

Closures are functions which can be invoked with arguments. You can define and invoke the functions at run time. Curly braces, '{ ' and '} ' are used to enclose a closure definition.
admin@localhost:/TEA> each {ls}{show info $it}
Name:TEA
Type:tea:2.1:TEA
Status:Running

Name:Agents
Type:tea:2.1:agents

Name:Users
Type:tea:2.1:users

Name:Groups
Type:tea:2.1:groups

Name:Roles
Type:tea:2.1:roles

Name:Realms
Type:tea:2.1:realms

Name:Machines
Type:tea:2.1:teaMachines

Name:Solutions
Type:tea:2.1:solutions

Json ComplexType

If the definition of TeaParam in a TeaOperation is a user-defined object, ensure that you use a String of the type: Json complexType .
'{"strA":"aa","strB":"bb"}'
Note: Use single quotation marks to wrap the JSON input in the single command mode. In the interactive mode, do not use quotation marks.