A friendly place for programming greenhorns!
Big Moose Saloon
Search
|
Java FAQ
|
Recent Topics
Register / Login
JavaRanch
»
Java Forums
»
Engineering
»
Linux / UNIX
Author
return value from java and assign it to a variable in shell script
Chandrasekaran SanthanaKrishnan
Greenhorn
Joined: Mar 29, 2011
Posts: 7
posted
Mar 29, 2011 04:34:23
0
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.
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.
Sanjeev Ba
Ranch Hand
Joined: Dec 31, 2006
Posts: 37
I like...
posted
Mar 29, 2011 18:54:10
0
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
I like...
posted
Apr 05, 2011 20:50:53
0
Sanjeev Ba wrote:
var1=`java Test`
Backticks are deprecated. Instead use $(...). You can nest it easily, and it is better readably.
#!/bin/bash var1=$(java Test) echo $var1
http://home.arcor.de/hirnstrom/bewerbung
I agree. Here's the link:
http://zeroturnaround.com/jrebel
subject: return value from java and assign it to a variable in shell script
Similar Threads
Question about <c:param> in JSTL
How to return a string number from shell script?
STRUTS 2 ERROR
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
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter