Java Reference
In-Depth Information
Here's the same command for Linux:
export PATH=$PATH:/usr/data/jython2.5.3/bin
export CLASSPATH=$CLASSPATH$:%JBOSS_HOME%/bin/client/
jboss-cli-client.jar
Ok, now we will create our first script that will basically return the JNDI view of our ap-
plication server.
Note
Be aware that Jython, just like Python, uses indentation to determine the code structure in-
stead of using braces or keywords. Therefore, do not use them randomly. An IDE might
help you with this—for Python you can use, for example, Vim with python-mode ( ht-
tps://github.com/klen/python-mode ) or Eclipse with the PyDev extension ( ht-
tp://pydev.org/ ) .
Create a file named script.py containing the following code:
from org.jboss.as.cli.scriptsupport import CLI
cli = CLI.newInstance()
cli.connect()
cli.cmd("cd /subsystem=naming")
result = cli.cmd(":jndi-view")
response = result.getResponse()
print 'JNDI VIEW ======================= '
print response
cli.disconnect()
Now execute the script with the following code:
jython script.py
As you can see, the code is very self-explanatory; we are importing the
org.jboss.as.cli.scriptsupport.CLI class, which is used to send commands
Search WWH ::




Custom Search