Solved

Executing shell script from java

Posted on 2013-06-13
4
440 Views
Last Modified: 2013-07-02
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.
0
Comment
Question by:Sreejith22
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 86

Accepted Solution

by:
CEHJ earned 300 total points
ID: 39245627
http://technojeeves.com/joomla/index.php/free/52-runtimeexec

Note particularly the issues around ensuring that stderr is read too and that streams are read in their own separate threads
0
 

Author Comment

by:Sreejith22
ID: 39246654
I went through the complete source given here :

http://technojeeves.com/tech/IOUtils.java?86c4bfb0a87399eb914bee8fe5a99da9=fae8cb49527f3cd2a46cff237a9d3e82

Sorry,did not understand what need to be done with that code for resolving the question I posted.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39246993
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
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 39292939
:)
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
The viewer will learn how to implement Singleton Design Pattern in Java.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question