A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Refactoring for Software Design Smells: Managing Technical Debt
this week in the
OO, Patterns, UML and Refactoring
Linux / UNIX
return value from java and assign it to a variable in shell script
Joined: Mar 29, 2011
Mar 29, 2011 04:34:23
I have a requirement where I am running a script and invoking a
program which will return a
This returned value must be assigned to a local variable using which i have to find diff between two files.
saving output in a local file and then cat the file and assign it to variable is also not working.
java myclass param1 param2 > localFile.txt fileName='cat localFile.txt'
below mentioned method is also not working:
out='java MyClass Param1 param2' out=$(java MyClass Param1 param2')
please give a solution
ps: I am running the shell script on solaris OS.
Joined: Dec 31, 2006
Mar 29, 2011 18:54:10
I tried out an example. You could try it in bash.
#seems to work for me.
Try and let me know.
Joined: Jun 02, 2003
Apr 05, 2011 20:50:53
Sanjeev Ba wrote:
Backticks are deprecated. Instead use $(...). You can nest it easily, and it is better readably.
#!/bin/bash var1=$(java Test) echo $var1
I agree. Here's the link:
subject: return value from java and assign it to a variable in shell script
How return a string from java program to the shell which invokes thee java command
Printing a file using Shell Script in Unix env called from a Java Application
STRUTS 2 ERROR
Question about <c:param> in JSTL
How to return a string number from shell script?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015