commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jörg Schaible <>
Subject Re: [cli] simple Java problem - please, help
Date Mon, 23 Feb 2009 09:57:35 GMT
Hi Alex,

Alexander Fooks wrote at Montag, 23. Februar 2009 09:48:

> Hello, All,
> My application received parameters from the Java command line.

Well, first of all you should always prepend the subject of a message posted
to this list with the commons module you're talking about. Otherwise it is
always hard to guess and a lot of pepole will not even read your mail.

> Some of parameter names have spaces inside.
> In W2K I use quotation marks and it works.
> In Linux (Red Hat) the same command line doesn't work:
> ./ -add -service -name serviceNew -application "Other TCP"
> -service_type PRIMARY -add_port TCP:DEFAULT:555


> This is script on Linux:
> java   -cp  .:./lib/commons-cli-1.1.jar cli.TestCli $*
> It's clear that Java VM does this wrong parsing of command line before
> of using commonCli.

Welcome to Unix shell programing. No it's not the Java VM that does it
wrong, it is your script that does not respect the shell behavior. While
the quoted param is properly passed as param to your *script*, the quotes
are the already resolved and $* is expanded with the plain value i.e.
without quotes. The Java VM has to interpret it as two params here.

> Could anybody help me?

Actually you want
 java   -cp  .:./lib/commons-cli-1.1.jar cli.TestCli "$@"

- Jörg

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message