简体   繁体   中英

how to run jar file assgin to variable and echo it out in shell script

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 !

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM