How to run JBoss EAP CLI in non-interactive mode

Solution Verified - Updated

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 7.x
    • 6.x

Issue

  • How to run JBoss CLI scripts in non interactive mode , is it possible?
  • How to execute multiple CLI commands in one attempt ?
  • How to use JBoss EAP CLI non-interactively for application deployment in both managed and standalone environments ?

Resolution

In order to run a command directly, one can use the command option together with the command to be executed as an argument to the CLI at the time of initializing, between quotation marks. Example with jboss-cli.sh -c:

#Go to bin directory inside jboss_home
cd $JBOSS_HOME/bin

#execute jboss-cli with -c option for connect, --controller for the  address, and the command option with quotation marks
$ ./jboss-cli.sh -c --controller=10.10.10.10:9999 command="/subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads,value=3000) "
{"outcome" => "success"}

Example Syntax:

The command goes between quotation marks:

$./jboss-cli.sh -c command="YOUR_CLI_COMMAND"
  • To execute multiple CLI commands in one attempt, Create a text file (say TMH.cli) having all the commands and just execute that file as shown below :
$ ./jboss-cli.sh -c --controller=127.0.0.1:9999 --file=/path/to/the/file/abc/TMH.cli

Deployment in non-interactive mode

To use JBoss CLI non-interactive mode for deploying an application in both managed and standalone environments users can use a following kind of examples:

In Standalone Mode:
$./jboss-cli.sh -c --controller=10.10.10.10:9999 command="deploy /path-up-to/your-app.war"
In Domain Mode:
$ ./jboss-cli.sh -c --controller=10.10.10.10:9999 command="deploy /path-up-to/your-app.war --server-groups=main-server-group"
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.