Open a UNIX terminal (with a remote login session) on JButton click

All,

-- The domain of this problem blurs the line which decides if this question has to be posed on a Java swing audience or a UNIX forum. To understand this problem apart from being a Java swing person, you would also need to have a basic understanding of UNIX concepts such as gnome-terminal, xterm and rsh --

I am creating a network monitoring GUI which has a JTable having many entries that pertains to various system information about nodes in a network. I have overridden the default cellEditor in the table with a custom TableCellEditor (camickr's archive) and have a column containing JButtons labelled with hostnames.

Now, when a user clicks on any of these buttons, I would like to open up a terminal (xterm or /usr/bin/gnome-terminal) followed by executing some commands on this NEW terminal shell. In other words, I would like to automate this process as if the user opens a terminal and then keys in commands to rsh into the remote host by specifying the hostname (which is the label on the JButton) and finally provide the user with this state, from where on she takes control on that remote login session.

I tried searching through various previous posts. I did find a related one:

http://forum.java.sun.com/thread.jspa?threadID=5180094&messageID=9699614#9699614

But I still have difficulty in getting my problem solved.

The following statements are executed when one such button (labelled by a hostname) is clicked:

.

.

.

publicvoid actionPerformed(ActionEvent e){

String hostname = e.getActionCommand();

fireEditingStopped();

System.out.println("probing: " + hostname);//This appears correctly on the console

Process p;

try{

p = Runtime.getRuntime().exec("/usr/bin/gnome-terminal");

BufferedReader in =new BufferedReader(new InputStreamReader(p.getInputStream()));

BufferedWriter out =new BufferedWriter(new OutputStreamWriter(p.getOutputStream()));

out.write("rsh -l root "+hostname);//attempting to remote login in the NEW shell (terminal)..... I guess :|

}catch (IOException e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

.

.

.

I guess I am not having control on the new terminal. Is there any way I could control the newly spawned shell?

Appreciate,

Rajiv

[2992 byte] By [toxiga] at [2007-11-27 6:53:46]
# 1
Alright...assuming gnome-terminal is in /usr/bin path,/usr/bin/gnome-terminal -e "<command>"would solve this problem
toxiga at 2007-7-12 18:28:34 > top of Java-index,Desktop,Core GUI APIs...