You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Alexander Fooks <af...@allot.com> on 2009/02/23 09:48:44 UTC

RE: simple Java problem - please, help

Hello, All,

 

My application received parameters from the Java command line.

 

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

=====================Input:

[-add]

[-service]

[-name]

[serviceNew]

[-application]

[Other]

[TCP]

[-add_port]

[TCP:DEFAULT:555] 

 

run1.bat -add -service -name serviceNew -application "Other TCP"
-service_type PRIMARY -add_port TCP:DEFAULT:555

=====================Input:

[-add]

[-service]

[-name]

[serviceNew]

[-application]

[Other TCP]

[-service_type]

[PRIMARY]

[-add_port]

[TCP:DEFAULT:555]

=====================End Input:

 

This is run script on W2K:

java -cp .;./lib/commons-cli-1.0.jar cli.TestCli %*

 

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.

 

Could anybody help me?

 

 

Best Regards

 

Alex Fooks

 


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


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

Posted by Jörg Schaible <jo...@gmx.de>.
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: simple Java problem - please, help

Posted by Alexander Fooks <af...@allot.com>.
Yes.
I already have the solution.


BR
Alex Fooks



-----Original Message-----
From: mickeydog [mailto:mickeydog@taosnet.com] 
Sent: Monday, February 23, 2009 3:18 PM
To: Commons Users List
Subject: Re: simple Java problem - please, help

Could it be an issue of case sensitivity?

Alexander Fooks wrote:
> Hello, All,
>
>  
>
> My application received parameters from the Java command line.
>
>  
>
> 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
>
> =====================Input:
>
> [-add]
>
> [-service]
>
> [-name]
>
> [serviceNew]
>
> [-application]
>
> [Other]
>
> [TCP]
>
> [-add_port]
>
> [TCP:DEFAULT:555] 
>
>  
>
> run1.bat -add -service -name serviceNew -application "Other TCP"
> -service_type PRIMARY -add_port TCP:DEFAULT:555
>
> =====================Input:
>
> [-add]
>
> [-service]
>
> [-name]
>
> [serviceNew]
>
> [-application]
>
> [Other TCP]
>
> [-service_type]
>
> [PRIMARY]
>
> [-add_port]
>
> [TCP:DEFAULT:555]
>
> =====================End Input:
>
>  
>
> This is run script on W2K:
>
> java -cp .;./lib/commons-cli-1.0.jar cli.TestCli %*
>
>  
>
> 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.
>
>  
>
> Could anybody help me?
>
>  
>
>  
>
> Best Regards
>
>  
>
> Alex Fooks
>
>  
>
>
>   

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


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


Re: simple Java problem - please, help

Posted by mickeydog <mi...@taosnet.com>.
Could it be an issue of case sensitivity?

Alexander Fooks wrote:
> Hello, All,
>
>  
>
> My application received parameters from the Java command line.
>
>  
>
> 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
>
> =====================Input:
>
> [-add]
>
> [-service]
>
> [-name]
>
> [serviceNew]
>
> [-application]
>
> [Other]
>
> [TCP]
>
> [-add_port]
>
> [TCP:DEFAULT:555] 
>
>  
>
> run1.bat -add -service -name serviceNew -application "Other TCP"
> -service_type PRIMARY -add_port TCP:DEFAULT:555
>
> =====================Input:
>
> [-add]
>
> [-service]
>
> [-name]
>
> [serviceNew]
>
> [-application]
>
> [Other TCP]
>
> [-service_type]
>
> [PRIMARY]
>
> [-add_port]
>
> [TCP:DEFAULT:555]
>
> =====================End Input:
>
>  
>
> This is run script on W2K:
>
> java -cp .;./lib/commons-cli-1.0.jar cli.TestCli %*
>
>  
>
> 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.
>
>  
>
> Could anybody help me?
>
>  
>
>  
>
> Best Regards
>
>  
>
> Alex Fooks
>
>  
>
>
>   

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