Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 2 Administering ActiveSpaces with the Admin CLI : Starting the Admin CLI

Starting the Admin CLI
To start the TIBCO ActiveSpaces Admin CLI, you must:
Setting the Required Environment Variables
To be able to run the Admin CLI, you must set environment variables to point to:
JAVA_HOME The location of the Java installation on your computer.
AS_HOME The location of the ActiveSpaces installation on your computer.
PATH Defines the path to AS_HOME and JAVA_HOME.
The easiest method to set the variables is in a script file (a command file in MS Windows or a shell script on UNIX platforms).
The following Windows command script sets the required environment variables for starting the Admin CLI in a command window.
Example 1 Windows Command File for Setting Environment Variables for the Admin CLI
@echo off
 
set AS_HOME=c:\tibco\as\2.1
set PATH=%AS_HOME%\lib;%AS_HOME%\bin;%PATH%
 
set JAVA_HOME=%DRIVE_C%\Program Files\Java\jdk1.6.0_24
set PATH=%PATH%;%JAVA_HOME%\bin;%JAVA_HOME%\lib
*I
Make sure that you prepend the AS_HOME\lib PATH setting and the AS_HOME\bin PATH setting to the PATH setting; for example:
Launching the Admin CLI
The default location of the Admin CLI program on Windows is:
C:\tibco\as\2.1\lib
To launch the CLI:
1.
2.
3.
cd C:\tibco\as\2.1\lib
java -jar as-admin.jar
 
The Admin CLI prompt appears:
as-admin>
You can now enter Admin CLI commands.
 
Using a script file to pass arguments when launching the Admin CLI
Using a script file, you can pass command line arguments when you launch the Admin CLI, as follows:
java -jar as-admin.jar -i admin-cmd-filename
The above usage information for as-admin can be obtained by invoking java -jar as-admin.jar-h from the ActiveSpaces lib directory in a command line window.
 
This mechanism allows execution of commands in a batch mode through the Admin CLI. There are several limitations on the structure of the file:
1.
2.
3.
Here 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 quit
.
Using the Admin CLI command export metaspace [to <filename>] (see export metaspace) will generate a file containing the schema for the existing 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
1.
Here is sample of the contents of such a 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'));
    ## This defines the key index to be of index type "hash" with     fields "key"
2.
 
   java -jar as-admin.jar-i c:\temp2\example01.txt.
Additional Characteristics of the Admin CLI Tool:
You can invoke a shell command by using the escape character’!’, for example, !dir or !ls to list the files in the current directory.
In most cases, the Admin CLI will start by using the connect command to connect to a metaspace.
For more information on discovery, see “Connecting to the Metaspace “in the TIBCO ActiveSpaces Developer’s Guide.
The Execute method
Admin CLI administrative commands (for example defining a space) can be executed directly from within an application. This is done by using the Metaspace object's execute method and passing it a string representing the Admin CLI command. A string is returned containing the output resulting from executing the command.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved