1

I am trying to run a jar file in a shell script. And I want to assign the out put of that jar file and echo it out. I tried something like below.

#!/bin/bash

$the_output = "$(java -jar portalOutputFormater.jar $1 $2 $3 $4  2>&1 )"

echo the_output

My java program returns the output as 'output=var1_var2_var3_var4" for the four input parameters. But I am getting the output as..

portaloutputformatter.sh: line 3: =output=var1_var2_var3_var4: command not found

What I am I doing wrong here? I just need to run my jar file then assign it to variable and output the variable.

Thank You !

1 Answer 1

5

Your bash syntax is all wrong. Here's a quick fix, but you do need to start learning some basics...

#!/bin/bash

the_output=$(java -jar portalOutputFormater.jar $1 $2 $3 $4 2>&1)

echo $the_output
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.