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
Solved

Executing shell script from java

Posted on 2013-06-13
4
435 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
  • 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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
difference between sorce folder and folder in eclipise 3 29
parse a file and get data out 11 78
Using sort and uniq to pare down large syslog 6 51
AWK:  END { statements } 2 19
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
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 “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

829 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