Just putting those commands in a file is also working for me.
[39](ironmaiden:jboss-as) >
/home/git/JBossAS/jboss-as/build/target/jboss-7.0.0.Beta3-SNAPSHOT/bin/jboss-admin.sh
--connect </tmp/shutdown.txt
=========================================================================
JBoss Admin Command-line Interface
JBOSS_HOME:
/home/git/JBossAS/jboss-as/build/target/jboss-7.0.0.Beta3-SNAPSHOT
JAVA:
/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/bin/java
JAVA_OPTS:
=========================================================================
Connected to localhost:9999
[localhost:9999 /] :shutdown
Communication error: java.util.concurrent.ExecutionException:
java.io.EOFException: Connection closed
[localhost:9999 /] quit
Closed connection to localhost:9999
I added a comment to the JBAS-9270 asking for the ability to execute an
input string as a series of commands as many interpreters/shells do.
On 4/6/11 2:00 PM, Brian Stansberry wrote:
The management API exposes a command "shutdown" on the root resource for
a standalone server.
Here's a hack that worked for me for executing that from the CLI:
pingguo:bin bstansberry$ (echo :shutdown; echo quit) | ./jboss-admin.sh
--connect controller=localhost:9999
=========================================================================
JBoss Admin Command-line Interface
JBOSS_HOME: .....
JAVA: .....
JAVA_OPTS:
=========================================================================
Connected to localhost:9999
[localhost:9999 /] :shutdown
Communication error: java.util.concurrent.ExecutionException:
java.io.EOFException: Connection closed
[localhost:9999 /] quit
Closed connection to localhost:9999
pingguo:bin bstansberry$
The "--connect" argument passed to jboss-admin.sh tells it to connect
when it starts, without a separate command after it starts. The
"controller=localhost:9999" bit tells it how to connect. In this case
it's unnecessary; since localhost:9999 is the default.
Once I merge JBAS-9839 there will be a --file=xxx.txt option whereby
multiple commands can be read from a file.
The hack I did with (echo :shutdown; echo quit) was to get the CLI to
read two commands from stdin: the server shutdown command and an
instruction that the CLI itself should exit. I'm sure there are better
ways to do that.
Alexey, WDYT about something like this:
./jboss-admin.sh --connect --exec=:shutdown
Basically --exec means "execute one command and exit".