You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Ashika Umanga Umagiliya <au...@biggjapan.com> on 2009/11/19 11:21:29 UTC

Commons CLI : Executing from shell script ?

Greetings all,

In my application I have used Commons CLI to parse command line arguments.
I want to run my JAR file using shell script because , I have to setup 
some environment variables.
But it seems that shell script messing around with argument order/number.

My shell script is as follows:


export ARCH=lx24-amd64
export SGE_ROOT=/SGE6/sge6.2
export LD_LIBRARY_PATH=$SGE_ROOT/lib/$ARCH/
#echo $SGE_ROOT
#echo $LD_LIBRARY_PATH
java -jar analyse.jar $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 
$16 $17 $18 $19 $20


But  when I run directly from shell using "java -jar analyse.jar ..... " 
everything works fine.

Any tips?

Thanks in advance.


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


Re: Commons CLI : Executing from shell script ?

Posted by Carsten Schlipf <ca...@yeap.de>.
In case of a space in an argument $* will not help, but $@.

Henri Yandell wrote:
> Does using $* help? Even if it doesn't, it would be more concise.
> 
> I'm assuming one of the variables you're passing through contains a
> space and is splitting things up after the quotes surrounding it are
> lost. Does the number of arguments increase?
> 
> Hen
> 
> On Thu, Nov 19, 2009 at 2:21 AM, Ashika Umanga Umagiliya
> <au...@biggjapan.com> wrote:
>> Greetings all,
>>
>> In my application I have used Commons CLI to parse command line arguments.
>> I want to run my JAR file using shell script because , I have to setup some
>> environment variables.
>> But it seems that shell script messing around with argument order/number.
>>
>> My shell script is as follows:
>>
>>
>> export ARCH=lx24-amd64
>> export SGE_ROOT=/SGE6/sge6.2
>> export LD_LIBRARY_PATH=$SGE_ROOT/lib/$ARCH/
>> #echo $SGE_ROOT
>> #echo $LD_LIBRARY_PATH
>> java -jar analyse.jar $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16
>> $17 $18 $19 $20
>>
>>
>> But  when I run directly from shell using "java -jar analyse.jar ..... "
>> everything works fine.
>>
>> Any tips?
>>
>> Thanks in advance.
>>
>>
>> ---------------------------------------------------------------------
>> 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
> 

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


Re: Commons CLI : Executing from shell script ?

Posted by Henri Yandell <fl...@gmail.com>.
Does using $* help? Even if it doesn't, it would be more concise.

I'm assuming one of the variables you're passing through contains a
space and is splitting things up after the quotes surrounding it are
lost. Does the number of arguments increase?

Hen

On Thu, Nov 19, 2009 at 2:21 AM, Ashika Umanga Umagiliya
<au...@biggjapan.com> wrote:
> Greetings all,
>
> In my application I have used Commons CLI to parse command line arguments.
> I want to run my JAR file using shell script because , I have to setup some
> environment variables.
> But it seems that shell script messing around with argument order/number.
>
> My shell script is as follows:
>
>
> export ARCH=lx24-amd64
> export SGE_ROOT=/SGE6/sge6.2
> export LD_LIBRARY_PATH=$SGE_ROOT/lib/$ARCH/
> #echo $SGE_ROOT
> #echo $LD_LIBRARY_PATH
> java -jar analyse.jar $1 $2 $3 $4 $5 $6 $7 $8 $9 $10 $11 $12 $13 $14 $15 $16
> $17 $18 $19 $20
>
>
> But  when I run directly from shell using "java -jar analyse.jar ..... "
> everything works fine.
>
> Any tips?
>
> Thanks in advance.
>
>
> ---------------------------------------------------------------------
> 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