jboss-cli --file exit on error

Latest response

why is the jboss-cli stopped after an error in the cli script? Is it possible to ignore errors?

Responses

Hi Paulo,

This issue was originally posted back in February, but as you seem to have encountered it more recently, could you provide some more information as Russell requested in his comment below?

Arjan - Can you explain a little more, or give an example, of what you are trying to achieve? If an error occurs while processing a CLI script, I would think it makes sense for processing to stop. If an error occurred, yet that error was ignored, the result may be that the changes you intended didn't take place, or in a worst-case scenario, unwanted changes occurred instead.

Russell

There are some cases when it would be useful to continue the processing. For example, I have a script that configure multiple host controllers. But for different environments or JBoss farms there are different number of servers. And If I want too use a template and not a custom script for every JBoss farm. So, If there is a "if" condition, for example, to continue if failed or stop it would solve many cases working with CLI and trying to minimize manual configuration changes.

It sounds like you're asking for the equivalent of "on error continue" (or "on error goto") which is really a bad idea.
You will be much better of when you script this properly using a JDK supported scripting language. This will offer all the control you might need. Please take a look at the examples: https://developer.jboss.org/wiki/AdvancedCLIScriptingWithGroovyRhinoJythonEtc

I do not think it is a bad idea to have "on error continue". It should be up to a admin how to proceed with the result. I am against "goto", but ability to stop or continue the script run gives a flexibility to the simplicity of CLI approach. Groovy or JS is fine but I do not want to go to the development process when I just need to configure AS. Also, having something is not necessary to be used. But can be used if necessary. :)

So to answer your question then it's not possible to ignore errors (they are errors and should not be ignored) as Tom and Russell mentioned. Especially in a script - you want to know if anything failed during set up believe me and not blindly ignore it.

If you want to you can create proper logic on errors using the JDK supported scripting language which is what is supported and enables you to add logic that a script just can't do as easily or as well.