High Quality JMS & AMQP Messaging.

Executing CLI Scripts

CLI is able to process CLI commands from a file. These files are called 'CLI Scripts'. To run a CLI script, put the filename as the 3rd parameter of the CLI command line. CLI processes these commands just like they were typed via the keyboard. Comments inside the scriptfiles could be marked with a '#' in the first column of the line.

Using the 'clis' shell script

Normally, CLI prompts for username/password after starting. To avoid this, define username/password as system properties on the commandline:

Example:

    java -Dcli.username=admin -Dcli.password=secret com.swiftmq.admin.cli.CLI \
          smqp://localhost:4001 plainsocket@router1 jmsusage.cli

The distribution contains 2 example CLI scripts, jmsusage.cli and shutdown.cli. The first one displays the current JMS connections and running JMS threads, the second one performs a shutdown on the distributions router1.

Here is the content of jmsusage.cli:

    # CLI-Script to show the actual JMS connections
    #
    sr router1
    lc sys$jms/usage
    exit

The transcript of using it (we've used the 'clis' shell script in the distributions scripts directory):

    $pamela>./clis admin secret jmsusage.cli
    Router 'router1' is available for administration.

    Entity List: Usage
    Description: List of all active JMS Connections

    Entities in this List:
    ----------------------
    pamela.iit.de:1037
    pamela.iit.de:1039

    $pamela>_

And here that of shutdown.cli:

    # CLI-Script to shutdown router1
    #
    sr router1
    halt
    exit

And the transcript:

    $pamela>./clis admin secret shutdown.cli
    Router 'router1' is available for administration.

    Router Halt in 10 Seconds.

    $pamela>_

Using the 'execute' CLI Command

SwiftMQ 7.3.0 introduces the "execute" CLI command which has the syntax

      execute <filename>

and can be used to executes CLI scripts during an interactive CLI session. The following example executes the CLI script "jmsusage.cli":

      Welcome to SwiftMQ!

      Username:
      Password:
      Trying to connect ... connected
      Router 'router1' is available for administration.
      Type 'help' to get a list of available commands.
      > execute jmsusage.cli

      Entity List: Usage
      Description: Active JMS Connections

      Entities in this List:
      ----------------------
      192.168.0.47:53409