Open new terminal, ssh to remote host and run a program to the remote host.All output to be viewed on new opened terminal
===

To be more specific, what i really want to do is to open two new terminals. From terminal_1 i want to ssh @host1 and run a program1 to host1. From terminal_2 i want to ssh @host2 and run a program2 to host2. I need the output of program1 to be viewed on terminal_1 and output of program2 to be viewed on terminal_2.

(I have managed to open xterm and ssh @host.I tried to pass a second command "&&java echo_1" but it does nothing at all)

Here is the code:

import java.io.*;

public class multi1 implements Runnable {

    public void run() {

	try {
		String ss = null;
        	Runtime obj = null;
		String[] newcmd = new String[]{"/usr/bin/xterm","-hold","-e","ssh andreas@192.168.0.0&&java echo_1"};
		
		Process p = Runtime.getRuntime().exec(newcmd);

        	BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
        	BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));

        	while ((ss = stdInput.readLine()) != null) {
            		System.out.println(ss);
        	}
    	}catch (IOException e) {
        	System.out.println("FROM CATCH" + e.toString());
    	}
    }

    public static void main(String[] args) throws Exception {
        Thread th = new Thread(new multi1());
        th.start();
	//Thread th2 = new Thread(new multi1());
	//th2.start();
    }
}

