You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Jörg Schaible <jo...@gmx.de> on 2009/02/23 10:57:35 UTC

Re: [cli] simple Java problem - please, help

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:
> 
>  
> 
> ./run1.sh -add -service -name serviceNew -application "Other TCP"
> -service_type PRIMARY -add_port TCP:DEFAULT:555

[snip]

> 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?

http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters

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

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


RE: Re: [cli] simple Java problem - please, help

Posted by Alexander Fooks <af...@allot.com>.
Hi, Jörg,

It's really works!
You are right. 
Many, many thanks for your help!

BR
Alex Fooks

-----Original Message-----
From: news [mailto:news@ger.gmane.org] On Behalf Of J?rg Schaible
Sent: Monday, February 23, 2009 11:58 AM
To: user@commons.apache.org
Subject: Re: [cli] simple Java problem - please, help

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:
> 
>  
> 
> ./run1.sh -add -service -name serviceNew -application "Other TCP"
> -service_type PRIMARY -add_port TCP:DEFAULT:555

[snip]

> 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?

http://www.gnu.org/software/bash/manual/bashref.html#Special-Parameters

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

- Jörg


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org