[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: OzoneAdmin on WinNT, can't add newuser
Mario Vackier wrote:
>
> Hi,
>
> I was trying to add a new user via OzoneAdmin on WinNT.
>
> The following method in org.ozoneDB.core.admin.AdminClient doesn't do
> what expected when I invoke
>
> ozoneAdmin newuser -name=kodak1 -id=102
>
> at the command-line.
>
> On NT the arguments are split into 5 parts
> (newuser,-name,kodak1,-id,102) instead of
> (newuser,-name=kodak1,-id=102).
>
> protected void newUser( String[] _args ) throws Exception {
> String name = null;
> int id = -1;
>
> // check command line arguments
> for (int i = 1; i < _args.length; i++) {
> String arg = _args[i];
>
> if (arg.startsWith( "-name=" )) {
> name = arg.substring( 6 );
> verboseOut.println ("name=" + name);
> }
> else if (arg.startsWith( "-id=" )) {
> id = Integer.parseInt( arg.substring( 4 ) );
> verboseOut.println ("id=" + id);
> }
> }
> try {
> admin.newUser( name, id );
> }
> catch( UserManagerExc e ) {
> out.println( "Unable to create new user: " + e.getMessage()
> );
> }
> }
>
> I have no idea and not much time (it's Friday you know, working is done)
> why it is splitting the tokens within a =-sign.
>
> Maybe you can replace the method (and the similar ones) so that the call
> style is.
>
> ozoneAdmin newuser -name kodak1 -id 102
>
> The code can then be something like this and then everything works fine
> with me.
>
> protected void newUser( String[] _args ) throws Exception {
> String name = null;
> int id = -1;
>
> // check command line arguments
> int i = 1;
> while (i< _args.length) {
> String arg = _args[i++];
>
> if (arg.equals( "-name" )) {
> name = _args[i++];
> verboseOut.println ("name=" + name);
> }
> else if (arg.equals( "-id" )) {
> id = Integer.parseInt( _args[i++] );
> verboseOut.println ("id=" + id);
> }
> }
> try {
> admin.newUser( name, id );
> }
> catch( UserManagerExc e ) {
> out.println( "Unable to create new user: " + e.getMessage()
> );
> }
> }
>
> Greetings
> Mario
I prefer this second type of command line parsing better as it allows
file completion to work at the command line for executables that take a
file or directory. There is also a GNU library to help parse command
lines but I haven't tried it. If the parsing was changed, commands would
look like the following:
ozone -d /path/to/my/objectbase
This would allow command line completion.
Eric :-)