Hi Leslie,
I had tried executing rsh from cmd prompt and its working fine. And i had applied the same in the following Java code. When i tried to execute "rsh <<hostname>> <<loginname>> simple" from the cmd prompt its returning the correct value. Here "simple" is a shell script in which im jus printing "Success". And this gets displayed when i execute the above mentioned command. But im not able to capture that output in the java code. I had tried capturing in 3 diff ways but none is returning the value.
Now how should i capture the return value ?
public void usingRSH()
{
try{
Runtime run = Runtime.getRuntime();
Process pro = run.exec("rsh <<hostname>> <<loginname>> simple");
pro.waitFor();
System.out.println("B4");
DataInputStream dataIn = new DataInputStream(pro.getInputStream());
while(dataIn.available() != 0){
System.out.println("DIS : " + dataIn.readLine());
}
BufferedReader in = new BufferedReader(
new InputStreamReader(pro.getInputStream()));
String line = null;
while ((line = in.readLine()) != null) {
System.out.println("BR : " + line);
}
BufferedReader out = new BufferedReader(new InputStreamReader(pro.getInputStream()));
while(out.read() != -1)
{
System.out.println("BReader : " + out.readLine());
}
System.out.println("After");
}catch(Exception expObj){
System.err.println("Error in usingRSH : " + expObj);
}
}