WildFly ships with a powerful Command Line Interface which can be run interactively or not. In this tutorial we will learn how to run CLI commands in non-interactive mode.
Running CLI commands in a File
The simplest option to run CLI commands in non-interactive mode is to include the commands in a text file and execute them as follows:
./jboss-cli -c --file=script.cli
In the above example, we have also included the -c (alias for –connect) to connect automatically to the default server address before running the commands.
Running CLI commands from the prompt
Another option is to include the CLI commands directly in the shell.
$JBOSS_HOME/bin/jboss-cli.sh -c "/subsystem=logging/logger=*:read-resource"
If you need to provide Username/Password on the command line, you can use the following options:
$JBOSS_HOME/bin/jboss-cli.sh -c controller=$JBOSS_IP:9990 --user=$USER --password=$property_value --command="/subsystem=logging:read-resource"