admin@glassfish.java.net

Re: --echo

From: Bill Shannon <bill.shannon_at_sun.com>
Date: Mon, 10 Aug 2009 16:04:29 -0700

kedar wrote on 8/10/09 3:53 PM:
>
>
> Bill Shannon wrote:
>> Can someone help me understand the background and use of the --echo
>> option to asadmin?
>>
>> At a very simple level this seemed to me to be like "sh -x", simply
>> echoing each command as its executed. This would be useful "asadmin
>> scripts" run in multimode, for instance.
>>
>> In v2, the --echo option would echo more than just the original command.
>> It would also echo most (all?) of the settings of the other asadmin
>> options, such as --interactive, --secure, --terse, etc. I've copied
>> that behavior in v3.
>>
>> However, this produces echo output that uses the old deprecated command
>> syntax, for example:
>>
>> $ asadmin --echo --terse version
>> version --host localhost --port 4848 --interactive=true --echo=true
>> --terse=true
>> ...
>>
>> changing that output to put the asadmin options first would be weird
>> unless it also included the word "asadmin", e.g.
>>
>> asadmin --host localhost --port 4848 --interactive=true --echo=true
>> --terse=true
>> version
>>
>> That would be fine except when the commands are being executed in a
>> multimode script (which seems to me like the primary use case).
>>
>> So, my question is, how important is it that --echo include values for
>> asadmin options that have not been specified? Would it be sufficient
>> if asadmin simply echoed the commands *as entered*?
>
> I don't know the history too well, but ...
> I have routinely used the --echo flag to see the default values of certain
> options. So, from that angle, it's useful that it echoes not only those
> options
> that users specified on the command line. This was compounded by the
> fact that
> some options may come from the environment variables. echo used to treat
> them
> all and produce an output that used to tell the user what the final
> command line
> looks like, which is sometimes useful.

That almost sounds like a "debugging" option. Or, if --terse=false
wasn't the default, that might be more like a "verbose" option.

> With echo now being an asadmin program option, I see that the situation
> gets
> trickier and we can make a case that we change the behavior of echo
> slightly, to
> echo only the given (and maybe default) "command options" along with
> program options. How about for example,
>
> $ asadmin --echo version
> asadmin program options: --host localhost --port 4848 --terse false
> --interactive true --secure false --echo false
> command: version --verbose false

So there would be two lines of output for each command?
Do you think anyone depends on the output format?
I hope not.

> Also, note that we should be consistent in the display. For example, in
> your
> example, not all options and their values are separated by an '=' or '
> '. We
> need to pick one.

I think I used =true/false for boolean options, mostly because I think
it's weird that that boolean options have an *optional* value, and
because I thought most people used that form when typing them.

If you want consistency, I would leave out the "=" from all of them.

> If this makes it complex, maybe we should add a command named "defaults"
> that
> shows the default values of asadmin program options and then we have to do
> none of this and just echo the given command line verbatim?

It would be very easy to add such a command. Note also that the "export"
command with no arguments will give you much of this, showing you which
program options have been set; try it.

> If you are worried about multimode, I think Byron has added a capability
> where
> asadmin logs all the commands in an asadmin "session" to a file for
> subsequent
> analysis of an asadmin run. Maybe we should document it more clearly?

Yes, that's useful for debugging. I'm not sure if it's documented at all.


Opinions from anyone else?