<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
CLI non-interactive mode
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/aloubyansky">Alexey Loubyansky</a> in <i>JBoss AS7 Development</i> - <a href="http://community.jboss.org/docs/DOC-17041">View the full document</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><h3>Commands in a file</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>version</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>We can execute this file like this</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>./jboss-admin.sh --file=test.cli</p><p>JBoss Admin Command-line Interface</p><p>JBOSS_HOME: /home/XXX/git/jboss-as/build/target/jboss-as-7.1.0.Alpha1-SNAPSHOT</p><p>JAVA_HOME: /opt/jdk/</p><p>java.version: 1.6.0_21</p><p>java.vm.vendor: Sun Microsystems Inc.</p><p>java.vm.version: 17.0-b16</p><p>os.name: Linux</p><p>os.version: 2.6.35.13-92.fc14.i686.PAE</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>connect</p><p>ls</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>./jboss-admin.sh --file=test.cli</p><p>Connected to standalone controller at localhost:9999</p><p>extension</p><p>core-service</p><p>path</p><p>subsystem</p><p>system-property</p><p>deployment</p><p>interface</p><p>socket-binding-group</p><p>Closed connection to localhost:9999</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The connection to the controller will be closed implicitly before the CLI session terminates.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>ls</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>./jboss-admin.sh -c --file=test.cli</p><p>Connected to standalone controller at localhost:9999</p><p>extension</p><p>core-service</p><p>path</p><p>subsystem</p><p>system-property</p><p>deployment</p><p>interface</p><p>socket-binding-group</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><h3>Commands as arguments</h3><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>If all you want to do is execute a single command, then you can specify it using --command argument, e.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>./jboss-admin.sh -c --command=ls</p><p>Connected to standalone controller at localhost:9999</p><p>extension</p><p>core-service</p><p>path</p><p>subsystem</p><p>system-property</p><p>deployment</p><p>interface</p><p>socket-binding-group</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>or just</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>./jboss-admin.sh -c ls</p><p>Connected to standalone controller at localhost:9999</p><p>extension</p><p>core-service</p><p>path</p><p>subsystem</p><p>system-property</p><p>deployment</p><p>interface</p><p>socket-binding-group</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>If you want to execute more than one command then you should use -commands argument and separate commands with commas, e.g.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>./jboss-admin.sh -c --commands="cd subsystem=web,ls"</p><p>Connected to standalone controller at localhost:9999</p><p>virtual-server</p><p>connector</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Note,  the quotes are necessary in this case because between cd and its argument there is a space.</p><p>Or a shorter version of the above</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><blockquote class="jive-quote"><p>./jboss-admin.sh -c "cd subsystem=web,ls"</p><p>Connected to standalone controller at localhost:9999</p><p>virtual-server</p><p>connector</p></blockquote><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Comment by <a href="http://community.jboss.org/docs/DOC-17041">going to Community</a></p>
        <p style="margin: 0;">Create a new document in JBoss AS7 Development at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=102&containerType=14&container=2225">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>