Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have written a shell script that will take a parameter, pass that parameter to Java command. But I get error during the execution.

Here is the script:

#The script takes an input, the file name to be styled and executes the java program based on it

echo "Hello World"
echo "The parameter passed is $1"
cd ~/CStyler/java/
`javac Main.java`
`java Main $1`

The error I get:

Hello World
The parameter passed is hello
CStyler.sh: 7: CStyler.sh: The: not found
share|improve this question
    
Possible duplicate of this Q&A –  utrecht Sep 14 '14 at 16:21

1 Answer 1

up vote 1 down vote accepted

You can use the following code :

java YourApp "$1"

And run your code like this :

./app.sh your_argument 
share|improve this answer
    
Yup got it! So what are these `` for? –  subham soni Sep 14 '14 at 12:54
    
excuse me what ? –  Kasra AD Sep 14 '14 at 12:55
    
In some shell scripts they execute the ls command like this ls, I asked what does these `` do? –  subham soni Sep 14 '14 at 12:56
    
it do nothing for me ! –  Kasra AD Sep 14 '14 at 13:03
    
They are used like a variable for what a command returns, example cd `pwd` would cd to the current directory (which you are already in, but i couldn't think of an example). –  DisplayName Jan 23 at 15:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.