Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

How to run UNIX shell script in JAVA?

I need to run UNIX script using JAVA.
Requirement is like that UNIX script will return an integer value and I have to read that integer value in java code and use that integer for further processing.
I don't have any idea about this. Please help me out of this situation with code example.

Thanks in advance.
Ashish
[342 byte] By [mcaashish] at [2007-11-11 7:06:37]
# 1 Re: How to run UNIX shell script in JAVA?
You can run it using exec method of Runtime Object. use this is in your code.

Runtime r = Runtime.getSystemRuntime();
r.exec("whatever you want to run");

Thanks
G.Rajasekhar
gulapala at 2007-11-11 22:39:17 >
# 2 Re: How to run UNIX shell script in JAVA?
Here's a reference you should read as a precaution:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
aniseed at 2007-11-11 22:40:17 >