Executing shell script from java

I need to execute a shell script from java code by passing the parameters. In short, the following command works perfect from a terminal and I need to get this executed from java code:

tom@tom-Inspiron-N4050:~/Downloads/myscripts$ ./test_final_6jun.sh test com/abc

In the above code "./test_final_6jun.sh" is the script and "test com/abc" is the parameter to be passed. How can I accomplish this using java code? Any help is much appreciated.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

CEHJConnect With a Mentor Commented:

Note particularly the issues around ensuring that stderr is read too and that streams are read in their own separate threads
Sreejith22Author Commented:
I went through the complete source given here :


Sorry,did not understand what need to be done with that code for resolving the question I posted.
public static void outputProcessStreams(final Process p) {

Open in new window

Is what you should use at first when you've created the Process with Runtime.exec
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.