WildFly CLI Scripting: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 81: Line 81:


=Using Variables=
=Using Variables=
<font color=red>TODO:


* JBoss EAP 6 : using variables in CLI scripts (jboss-cli.sh) https://access.redhat.com/solutions/321513
* JBoss EAP 6 : using variables in CLI scripts (jboss-cli.sh) https://access.redhat.com/solutions/321513
Line 86: Line 88:
Also see [[#Sending_Commands_into_jboss-cli.sh.27s_stdin|Sending Commands into <tt>jboss-cli.sh</tt>'s <tt>stdin</tt>]] above.
Also see [[#Sending_Commands_into_jboss-cli.sh.27s_stdin|Sending Commands into <tt>jboss-cli.sh</tt>'s <tt>stdin</tt>]] above.


<font color=red>
I've seen this example, how does it work, how is Host1_Name defined?
I've seen this example, how does it work, how is Host1_Name defined?



Revision as of 00:19, 23 February 2016

Internal

Overview

This article describes various aspects of using CLI as a command-line execution tool - as opposite to an interactive session tool.

Connection to a Host Controller

In order to be able to interact with a host controller, CLI must be connected. For options on how to connect see:

Connect to a Controller

Executing a Single Command

Any word or phrase without white spaces in it is assumed to be a command. The --command argument optionally precedes it.

After a command is executed, the CLI will terminate the session.

Example:

jboss-cli.sh -c [--command=]ls

If a command requires space-separated arguments, command and the arguments should be enclosed is single quotes:

jboss-cli.sh -c [--command=]'deploy ./test.war --server-groups=web-frontend'

Executing Multiple Commands Specified on Command Line

In order to execute multiple commands (individual commands are assumed not to contain spaces), specify them in a comma separated list at the end of the argument list. Spaces are not allowed. The --commands argument optionally precedes it.

After the last command in the sequence is executed, the CLI will terminate the session.

Example:

jboss-cli.sh -c [--commands=]ls,pwd

If a command requires space-separated arguments, command and the arguments should be enclosed is single quotes:

jboss-cli.sh -c [--commands=]ls,'deploy ./test.war --server-groups=web-frontend'

Executing a Sequence of Commands Listed in a File

jboss-cli.sh -c --file=./commands.cli

where /commands.climay contain multiple commands, one per line. Individual commands may contain spaces. Example:

pwd
ls
deploy servlet-example.war --force

Sending Commands into jboss-cli.sh's stdin

#!/bin/bash

# ...

jboss-cli.sh -c <<EOF
batch
#deploy target/playground.war --server-groups=main-server-group
deploy target/playground.war --force
run-batch
EOF

Using Variables

TODO:

Also see Sending Commands into jboss-cli.sh's stdin above.

I've seen this example, how does it work, how is Host1_Name defined?

/host=$Host1_Name:write-local-domain-controller
reload --host=$Host1_Name

batch/run-batch

TODO