4 Replies Latest reply on Sep 2, 2013 3:31 AM by bwallis42

    CLI scripts: blank lines and comments?

    bwallis42

      I have a number of scripts for configuring various server things for my application (adding infinispan caches, configuring modeshape repositories, adding JMS topics, etc). These are intended to be run using jboss-cli.sh like so:

       

      bin/jboss-cli.sh --connect --file=modeshape.cli
      

       

      Some of these scripts are getting somewhat complex (50+ lines) and really require some comments in them to aid maintenance and understanding. But as far as I can workout, there is no supported comment syntax for these style of scripts and even blank lines break the script execution.

       

      So the question is, is there a supported comment syntax? If not, can this be added?

       

      I do have a simple groovy script that I can use to support my own comment syntax that strips out the comments and blank lines and then runs the script but this makes my scripts non-portable to others and one of the scripts is intended to be generally useful for the modeshape community.

       

      thanks.

        • 1. Re: CLI scripts: blank lines and comments?
          jaikiran

          I'll check with Alexey to see if this is supported and if not then whether he thinks this a feature we would like to have in WildFly.

          • 2. Re: CLI scripts: blank lines and comments?
            bwallis42

            What I posted was not quite correct, I think I am misunderstanding batch commands.

             

            Running

            % bin/jboss-cli.sh --connect 'run-batch --file=../Hg-Harvey/harvey-all/modeshape.cli'
            Failed to create batch from /Users/bwallis/InfoMedix/Harvey/jboss-eap-6.1/../Hg-Harvey/harvey-all/modeshape.cli: '#' is not a valid operation name.
            

             

            fails but if I run

             

            % bin/jboss-cli.sh --connect --file=../Hg-Harvey/harvey-all/modeshape.cli
            

             

            then the script runs as expected so it is the run-batch command that doesn't seem to accept comments. I've also noticed that you cannot have 'if' commands in a batch or split a command across multiple lines (with '\'s at the end of the lines) or have blank lines in the file.

             

            What I am looking for is a  way to execute a complicated script atomically (as batch mode does) but I want to comment and structure the script so that it is resilient and maintainable and also use if/then/else.

            • 3. Re: CLI scripts: blank lines and comments?
              sfcoy

              There's a sample CLI script at https://docs.jboss.org/author/display/AS71/CLI+Recipes#CLIRecipes-ScriptedConfiguration which worked OK the last time I tried it.

               

              What version of JBossAS/WildFly are you using?

              1 of 1 people found this helpful
              • 4. Re: CLI scripts: blank lines and comments?
                bwallis42

                Stephen Coy wrote:

                 

                There's a sample CLI script at https://docs.jboss.org/author/display/AS71/CLI+Recipes#CLIRecipes-ScriptedConfiguration which worked OK the last time I tried it.

                 

                What version of JBossAS/WildFly are you using?

                 

                I just tried a cut down version of demo.cli (including comments and blank lines) and it runs for me as well using --file=demo.cli but (after removing the batch and run-batch commands from demo.cli) it cannot be run using the "run-batch --file=demo.cli". I'm surprised that run-batch seems to expect a different (more limited) input format, ie: no if/then/else, comments or blank lines.

                 

                The main issue for me is the lack of if/then/else support in batch mode, I don't need to use 'run-batch --file' if it doesn't allow comments, I'll just use the command line '--file' option.

                 

                I'm running EAP 6.1.0.GA