Unix/Linux Go Back    


Shell Programming and Scripting Unix shell scripting - KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and shell scripts and shell scripting languages here.

How to make bash wrapper for java/groovy program with variable length arguments lists?

Shell Programming and Scripting


Tags
argument list, bash, variable length

Closed Linux or Unix Question    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 11-18-2010
siegfried siegfried is offline
Registered User
 
Join Date: Oct 2005
Last Activity: 8 February 2015, 3:29 PM EST
Location: Bellevue, WA
Posts: 125
Thanks: 0
Thanked 0 Times in 0 Posts
How to make bash wrapper for java/groovy program with variable length arguments lists?

The following bash script does not work because the java/groovy code always thinks there are four arguments even if there are only 1 or 2. As you can see from my hideous backslashes, I am using cygwin bash on windows.


Code:
export CLASSPATH=${GROOVY_HOME}\\embeddable\\groovy-all-1.7.4.jar\;c:\\Documents\ and\ Settings\\a-sheintze\\My\ Documents\\eclipse-workspace\\js\\grep\\src\\siegfried\\bin\;.  
java siegfried.grep $1 $2 $3 $4

How can I fix this problem with bash or some other shell?

I would like to know how to fix this problem with cmd.exe but I fear this is the wrong forum for that! (If anyone knows, please let me know!)

Thanks,
siegfried

Last edited by siegfried; 11-18-2010 at 02:27 PM..
Sponsored Links
    #2  
Old Unix and Linux 11-18-2010
Corona688 Corona688 is offline Forum Staff  
Mead Rotor
 
Join Date: Aug 2005
Last Activity: 26 May 2015, 6:40 PM EDT
Location: Saskatchewan
Posts: 20,665
Thanks: 894
Thanked 3,658 Times in 3,421 Posts
The special variable "$@" expands to all arguments, even when quoted like that. When not quoted, it might split on spaces in filenames, so keep it quoted just as shown.
Sponsored Links
Closed Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to make 2 separate arguments in 1 bash script? guitarscn Shell Programming and Scripting 4 08-31-2010 05:12 PM
Make variable length record a fixed length jclanc8 Shell Programming and Scripting 3 10-03-2009 08:24 PM
Make a list in bash out of arguments jolecanard Shell Programming and Scripting 4 07-02-2009 04:23 PM
using a variable from java program in unix inquisitive101 UNIX for Dummies Questions & Answers 1 01-14-2009 08:24 AM



All times are GMT -4. The time now is 09:36 PM.