r5 - 24 Apr 2008 - 18:04:08 - BeckyHYou are here: Wiki >  AppLogic23 Web > AdvScripting
ALERT! AppLogic 2.3 Beta Documentation The latest production release is AppLogic 3.0.30

Scripting CLI Commands

All of the commands that may be executed from the AppLogic Shell may also be executed from a remote client via ssh.

In all syntax examples, controllerhost is the hostname of the AppLogic controller being accessed. It is assumed that the client has set up an SSH agent to provide the necessary identity keys for access authorization or that a valid access key is otherwise provided to the SSH utility (e.g., via a command-line option or a configuration file). Regardless of the method used for supplying the access options, the client may only use an SSH2 private key (RSA or DSA) and must request access to the controller as 'root'. The corresponding public key must have been installed on the controller via the Web interface or by another user that has shell access to the controller.

NEW If you are using GNU bash as your shell, a set of shell functions is available for conveniently accessing the CLI commands from your shell, either interactively or in a script. See Client-side Macros.

ssh root@controllerhost entity command [args]

execute a single 3t shell command (command) on the controller

ssh root@controllerhost command entity [args]

same as above, with command and entity name swapped. Both syntax variants are accepted by the 3t shell

IDEA! Note: If you are connecting using a maintainer key, you must execute the commands in the following manner:

ssh root@controllerhost 3t entity command [args]

ssh root@controllerhost 3t command entity [args]

IDEA! If you wish to see additional progress as the script is executing, execute ssh with the -t option.

IDEA! Most commands also support the following additional parameters:

  • --quiet - Display only error descriptions and specific output.
  • --progress_on_stdout - Display progress to STDOUT rather than STDERR.

Script-only CLI Commands

Following are remote commands intended for advanced scripts and for implementing interactive shell interfaces that have client-side code. See ClientSideMacros for an example of such an interface, implemented for the GNU bash shell.

Appliance Shell Access

ssh [-t] controllerhost sh [args]

This command has the same function as the ssh command in the CLI interface, but is intended only for direct invocation as shown above and cannot be accessed through the interactive AppLogic shell prompt. It provides automatic setup of pseudo-terminal on the target appliance, to allow transparent use of interactive commands that require a tty (e.g., the 'vi' editor).

Invoking Commands with "current application"

ssh controllerhost =appname command [args]

This is a variation of the normal non-interactive command invocation described above, which provides a "current application" for the AppLogic CLI command. It is equivalent to executing the following two commands from the interactive shell:

ca appname
command [args]

Although each individual CLI command that supports 'current application' also allows an explicit application name to be specified, this alternative way of providing an application name is useful for client scripts that have their own notion of a 'current application' and also use a common function to invoke the remote AppLogic commands. This way, the function that does the actual remote command invocation does not need to know the command syntax and whether the particular command takes an application as an argument at all - it simply puts the current application name as the first word in the command and lets the AppLogic remote shell apply its own rules for using 'current application'.

Here's a simple example (GNU bash), which defines a function named '3t', to be used for invoking remote commands:

function 3t() { ssh $CONTROLLER =$APP "$@" ; }

With this function, one just has to set their controller host and current application, and start using remote commands from the local shell by prefixing them with 3t e.g.:

CONTROLLER=ctl.3tera.net
APP=TWiki

3t grid info
3t app list  # in this command, the current app name doesn't matter
3t app start # here, the current application name will actually be used

... etc.


-- BeckyH - 13 Jun 2006
 
Copyright © CA 2005-2011. All Rights Reserved.
%