Return value from UNIX to JAVA

Hi all,

is there any way to return value from UNIX to JAVA application.
I have my source code like this:

application.java

Runtime runtime = Runtime.getRuntime();  
Process p = runtime.exec(myscript);

myscript.sh

text="Hello World"
echo $text

How to return the "Hello World" text to the application.java ??

THanks in advance.. :slight_smile:

Your myscript.sh is fine...
In your Java code, you need to assign the value to a variable.

OK noted.
I will assign the value to the variable. But how do I get the value from the UNIX ?

Thanks..

According to the javadoc, Runtime.exec() returns a Process object that allows you to get information about the process. I found the exitValue() method and that is likely what you need.

Process (Java Platform SE 6))