salut tt le monde!!!
ça y est c'est presque fait........!!!

mais j aurai encore besoin d un t petit cup de pouce....
je suis parvenu a ouvrir une connexion sur un serveur telnet via mon programme mais je n arrive toujour pas à executer une cmd sur le dos de la machine distante.....et je n arrive pas a trouver où est le probleme:
est ce que qq1 peut m aider pleaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz!!!!
public class test {
public static void main(String[] args) {
try {
TelnetSample telnet = new TelnetSample( "192.123.1.62", "test","test" );
telnet.sendCommand( "dir" );
telnet.disconnect();
}
catch( Exception e ) {
e.printStackTrace();
}
}
}
________________________________________________________________________________
___
public class TelnetSample
{
private TelnetClient telnet = new TelnetClient();
private InputStream in;
private PrintStream out;
private char prompt = '>';
public TelnetSample( String server, String user, String password ) {
try {
// Connect to the specified server
telnet.connect( server, 23 );
// Get input and output stream references
in = telnet.getInputStream();
out = new PrintStream( telnet.getOutputStream() );
// Log the user on
readUntil( "User ID: " );
write( user );
readUntil( "password:" );
write( password );
// Advance to a prompt
readUntil( prompt + " " );
}
catch( Exception e ) {
e.printStackTrace();
}
}
public String readUntil( String pattern ) {
try {
char lastChar = pattern.charAt( pattern.length() - 1 );
StringBuffer sb = new StringBuffer();
// boolean found = false;
char ch = ( char )in.read();
while( true ) {
System.out.print( ch );
sb.append( ch );
if( ch == lastChar ) {
if( sb.toString().endsWith( pattern ) ) {
return sb.toString();
}
}
ch = ( char )in.read();
}
}
catch( Exception e ) {
e.printStackTrace();
}
return null;
}
public void write( String value ) {
try {
out.println( value );
out.flush();
//System.out.println( value );
}
catch( Exception e ) {
e.printStackTrace();
}
}
public String sendCommand( String command ) {
try {
write( command );
return readUntil( prompt + " " );
}
catch( Exception e ) {
e.printStackTrace();
}
return null;
}
public void disconnect() {
try {
telnet.disconnect();
}
catch( Exception e ) {
e.printStackTrace();
}
}
}
alors une idée?!!!!!!!! merci d avance.................;;