execute a telnet application under java
843798Apr 15 2003 — edited May 20 2003hello
I would like to execute the telnet unix application in a java GUI.
I'd like to use the runtime.exec method but i dont know how to catch the info coming from the telnet
the telnet don't send data into the process inputstream but i dont know why
the read method never return -1 like it said in the api
private usetelnet(){
//Cr�ation d'une procedure de commandes externes
Runtime runT= Runtime.getRuntime() ;
try{
//Cr�ation du processus
System.out.println("telnet is running");
//Process process=runT.exec("telnet);
Process process=runT.exec("/bin/tcsh -c "+cmd) ;
OutputStream in=process.getOutputStream();
//R�cup�ration du flux de sortie
fluxSortie=process.getInputStream();
}catch (Exception e){System.out.println(e);}
BufferedReader d = new BufferedReader(new InputStreamReader(fluxSortie));
String result =new String("");
int c;
try{
while((c = d.read())!= -1) { // freeze here
//
if (c != -1){
//System.out.println(S);
System.out.print( (char) c);
result = result + (char) c;
}
}
}catch (Exception e){System.out.println(e);}
System.out.println(result);
.........
}