Using a Script File to Pass Arguments

Using a script file, you can pass commands for the Admin CLI to begin executing when you launch the Admin CLI.

as-admin -i admin-cmd-filename
Note: Comments can be inserted into the script file by starting a line with #, as follows:
# this is a comment

This mechanism allows execution of commands in a batch mode through the Admin CLI. There are several limitations on the structure of the file:

  • No special characters are allowed.
  • Each line is executed sequentially by the Admin CLI. Therefore, each individual command must be entered on one line.
  • The Admin CLI will not automatically exit and return to the shell after executing the commands of the file unless the script file contains a quit command.

The following is an example:

######
connect name "UserMetaspace" discovery "tibpgm"
show members
export metaspace to "export.txt"
quit
######

This will connect to a metaspace, display members, export the metaspace, and exit the Admin CLI .

Note: The export metaspace [to <filename>] Admin CLI command generates a file containing the schema for the existing metaspace. For more details, see export metaspace. The admin-cmd-filename value can be the path to this generated file. In this way, a new metaspace can be created using the exported metaspace schema.

Example

The following example demonstrates the following:
  • invoking the Admin CLI using a script file to connect to a metaspace.
  • creating a space.

Here is an example of the contents of the script file. In this example, the file is named example01.txt and is located in the directory C:\temp2.

connect name 'ms' discovery 'tibpgm' listen 'tcp'
define space name 'testspace' (field name 'key' type 'integer', 
field name 'value' type 'string') key (type 'hash' fields ('key'))
Launch the Admin CLI using the following syntax:
as-admin -i c:\temp2\example01.txt