Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

execute a telnet application under java

843798Apr 15 2003 — edited May 20 2003
hello

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);
.........


}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 17 2003
Added on Apr 15 2003
3 comments
276 views