wood burning stoves 2.0*
The moose likes Linux / UNIX and the fly likes return value from java and assign it to a variable in shell script Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "return value from java and assign it to a variable in shell script" Watch "return value from java and assign it to a variable in shell script" New topic
Author

return value from java and assign it to a variable in shell script

Chandrasekaran SanthanaKrishnan
Greenhorn

Joined: Mar 29, 2011
Posts: 7
I have a requirement where I am running a script and invoking a java program which will return a string (filename).

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.



below mentioned method is also not working:




please give a solution


ps: I am running the shell script on solaris OS.
Sanjeev Ba
Ranch Hand

Joined: Dec 31, 2006
Posts: 40

I tried out an example. You could try it in bash.

#!/bin/bash
var1=`java Test`
echo $var1

#seems to work for me.

Try and let me know.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Sanjeev Ba wrote:
var1=`java Test`


Backticks are deprecated. Instead use $(...). You can nest it easily, and it is better readably.


http://home.arcor.de/hirnstrom/bewerbung
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return value from java and assign it to a variable in shell script
 
Similar Threads
Printing a file using Shell Script in Unix env called from a Java Application
Question about <c:param> in JSTL
How return a string from java program to the shell which invokes thee java command
STRUTS 2 ERROR
How to return a string number from shell script?