on 02-18-2008 6:58 AM
Hi !!!!!!!!! Can anybody plz suggest me an approach for the following queries -
1. How to execute a unix script through a java program ?
2. How to send the o/p of the script to a java program so that it can be used .
import java.io.*;
public RunScript
{
public static void main(String args[])
{
try
{
Process p = Runtime.getRuntime().exec("script.sh");
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
while ((line = input.readLine()) != null)
{
System.out.println(line);
}
input.close();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.