Advanced WildFly CLI: variables and aliases

In this short tutorial we will explore two not so well known features of WildFly CLI: creating variables (and reading them at startup) and creating persistent alias for functions.

Let’s start from the first: The CLI has a set function that can be used to assign a certain path of the server model to a variable. Example

set s1=/host=master/server=server-one

This is quite useful in domain mode as you can include references to host and profiles in variables so that you can easily replicate scripts on different servers. Example:


The problem here is that variables set within the CLI session will be lost at the end of the session. Luckily the .jbossclirc file comes to rescue us. Include the variables in this file (available in the “bin” folder of your server installation):

# .jbossclirc
set s1=/host=master/server=server-one
set s2=/host=master/server=server-two

Now restart the CLI and issue a set command to check the available variables:

[domain@localhost:9990 /] set

Good, now let’s move on another topic, we will discuss about aliases. WildFly CLI can use aliases pretty mich the same you would do it in a Linux Box:

[domain@localhost:9990 /] alias ll='ls'
[domain@localhost:9990 /] ll
core-service                    management-client-content       domain-organization=undefined   name=Unnamed Domain             release-version=2.0.10.Final    
deployment                      path                            launch-type=DOMAIN              namespaces=[]                   schema-locations=[]             
deployment-overlay              profile                         local-host-name=master          process-type=Domain Controller  
extension                       server-group                    management-major-version=4      product-name=WildFly Full       
host                            socket-binding-group            management-micro-version=0      product-version=10.0.0.Final    
interface                       system-property                 management-minor-version=0      release-codename=Kenny

As for variables, the alias created in a CLI session are not persistent. Since the CLI is derived from the Aesh project ( , aliases can be defined in the .aesh_aliases within the user’s home folder (Not WildFly home!).

Let’s test it. We will add the following alias in $HOME/.aesh_aliases

alias create='/subsystem=ejb3/strict-max-bean-instance-pool=demo:add(max-pool-size=10)'

Now start the CLI and test it:

[francesco@localhost bin]$ ./ -c
[standalone@localhost:9990 /] alias
alias create='/subsystem=ejb3/strict-max-bean-instance-pool=demo:add(max-pool-size=10)'
[standalone@localhost:9990 /] create
{"outcome" => "success"}

You could be also interested in the following tutorial:  Using properties in CLI scripts