Alexey Loubyansky [
http://community.jboss.org/people/aloubyansky] created the document:
"CLI non-interactive mode"
To view the document, visit:
http://community.jboss.org/docs/DOC-17041
--------------------------------------------------------------
Normally, jboss-admin.sh (or jboss-admin.bat) launches a command line session in an
interactive mode, meaning it is prompting the user to type in commands and operations and
prints the results of the performed actions in the same terminal window for the user to
see. There is also another (non-interactive) mode to execute commands and operations that
doesn't require typing them after the prompt. The commands can be stored in a file
which can be specified as an argument to jboss-admin.sh (or jboss-admin.bat) or even the
commands themselves can be specified as arguments to jboss-admin.sh (or jboss-admin.bat).
In this case, the CLI session will not display the prompt but just execute the commands
and operations listed in the file or specified as the arguments to jboss-admin.sh (or
jboss-admin.bat) and quit after the last command has been executed.
h3. Commands in a file
If there is a sequence of commands and/or operations that need to be executed regularly,
they can be stored in a file one command or operation per line and this file can be
specified as the input source for the CLI. E.g. suppose we have a file test.cli with the
following content:
version
We can execute this file like this
./jboss-admin.sh --file=test.cli
JBoss Admin Command-line Interface
JBOSS_HOME: /home/XXX/git/jboss-as/build/target/jboss-as-7.1.0.Alpha1-SNAPSHOT
JAVA_HOME: /opt/jdk/
java.version: 1.6.0_21
java.vm.vendor: Sun Microsystems Inc.
java.vm.version: 17.0-b16
os.name: Linux
os.version: 2.6.35.13-92.fc14.i686.PAE
The CLI session is terminated after all the commands and operations have been executed.
Note, the CLI doesn't automatically connects to the controller. So, if you want to
execute a command or an operation which requires a connection to the controller, you can
either add connect command to the file, e.g.
connect
ls
./jboss-admin.sh --file=test.cli
Connected to standalone controller at localhost:9999
extension
core-service
path
subsystem
system-property
deployment
interface
socket-binding-group
Closed connection to localhost:9999
The connection to the controller will be closed implicitly before the CLI session
terminates.
Or instead of adding the command to the file, you could add --connect (or its shorter
version -c) argument to jboss-admin.sh (or jboss-admin.bat), e.g.
ls
./jboss-admin.sh -c --file=test.cli
Connected to standalone controller at localhost:9999
extension
core-service
path
subsystem
system-property
deployment
interface
socket-binding-group
h3. Commands as arguments
If all you want to do is execute a single command, then you can specify it using --command
argument, e.g.
./jboss-admin.sh -c --command=ls
Connected to standalone controller at localhost:9999
extension
core-service
path
subsystem
system-property
deployment
interface
socket-binding-group
or just
./jboss-admin.sh -c ls
Connected to standalone controller at localhost:9999
extension
core-service
path
subsystem
system-property
deployment
interface
socket-binding-group
If you want to execute more than one command then you should use -commands argument and
separate commands with commas, e.g.
./jboss-admin.sh -c --commands="cd subsystem=web,ls"
Connected to standalone controller at localhost:9999
virtual-server
connector
Note, the quotes are necessary in this case because between cd and its argument there is
a space.
Or a shorter version of the above
./jboss-admin.sh -c "cd subsystem=web,ls"
Connected to standalone controller at localhost:9999
virtual-server
connector
--------------------------------------------------------------
Comment by going to Community
[
http://community.jboss.org/docs/DOC-17041]
Create a new document in JBoss AS7 Development at Community
[
http://community.jboss.org/choose-container!input.jspa?contentType=102&am...]