-1

I have a bash script that calls the java program .

java java.org.test -h "abc" The class computes the value of a specific string and this value is required by the bash script. and I should not be printing this value on the console.

How can this be done? Any suggestions here?

ursd
  • 45
  • 6

1 Answers1

0

TEST_RESULT=$(java java.org.test -h "abc") or java java.org.test -h "abc" > /dev/null

  • But how do I make sure java.org.test is returning string? as the main class is always void. – ursd Sep 13 '20 at 18:33
  • @deepthi urs Java and Bash don’t share type information. Everything is passed as a string (an input or output stream). So, when you print in Java, you can capture it in Bash as suggested above. – dantiston Sep 13 '20 at 18:37
  • @dantiston I have many statements that will be printed using System.out.println and only one among them needs to be the output to bash script. Will that be possible? – ursd Sep 13 '20 at 18:45
  • @deepthi urs sure, but I’m not sure I understand what you’re trying to do? It would be best to see your code with a [minimum, reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) and a specific issue you’re running into. If you’re going to print lots of stuff to bash and then only print some stuff to console, it’s probably a good idea to not print it to bash in the first place? But it’s hard to tell without more context. – dantiston Sep 13 '20 at 18:55