IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Exécution telnet Apache Commons


Sujet :

Android

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre régulier
    Homme Profil pro
    technicien a tout faire...
    Inscrit en
    Janvier 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : technicien a tout faire...
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Janvier 2013
    Messages : 7
    Par défaut Exécution telnet Apache Commons
    Bonjour,
    Je me permet de poser une question en ce qui concerne cette classe.
    Je tente de men servir sur android mais je me tape une exception vide lors du telnet.connect.
    Je me sert de apache commons et de la classe auto ci-dessus.
    Je ne peux pas poster lexemple full ce soir mais jespere demain.

    Peut etrr que quelqu'un a deja eu des soucis avec apache commons net et android? Notament pour les socket?

    Merci d'avance.

  2. #2
    Membre régulier
    Homme Profil pro
    technicien a tout faire...
    Inscrit en
    Janvier 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : technicien a tout faire...
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Janvier 2013
    Messages : 7
    Par défaut
    Rebonjour à tous,

    Pour mon problème de connect, je pense que je devais mal avoir interprété l'erreur. en faite c'est au moment du

    out = new PrintStream(telnet.getOutputStream());
    Que mon exception est générée.
    Mon code un peut modifié de la classe précédente est :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    package com.example.telnetv2;
    import org.apache.commons.net.telnet.EchoOptionHandler;
    import org.apache.commons.net.telnet.InvalidTelnetOptionException;
    import org.apache.commons.net.telnet.SuppressGAOptionHandler;
    import org.apache.commons.net.telnet.TelnetClient;
    import org.apache.commons.net.telnet.TerminalTypeOptionHandler;
     
    import android.app.AlertDialog;
     
     
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.io.OutputStreamWriter;
    import java.io.PrintStream;
    import java.net.SocketException;
     
    public class AutomatedTelnetClient {
     private TelnetClient telnet = new TelnetClient();
     private InputStream in;
     private PrintStream out;
     //private OutputStream out;
    //private OutputStreamWriter out2;
     private String prompt = ">";
     
    public AutomatedTelnetClient(String server, String user, String password) {
     try {
    	 //telnet.setDefaultTimeout(10000);
    	 int port = 23;
     
    	 MainActivity.ResultatConnection = "avant connect";
         TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
         EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
         SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
         try
         {
             telnet.addOptionHandler(ttopt);
             telnet.addOptionHandler(echoopt);
             telnet.addOptionHandler(gaopt);
         }
         catch (InvalidTelnetOptionException e)
         {
           	 MainActivity.ResultatConnection = "erreur params";
        	 MainActivity.ResultatConnection.concat(e.getMessage());
         }
     
         try {
        	 telnet.connect(server, port);
         }catch (SocketException e) {
         e.printStackTrace();
    	 MainActivity.ResultatConnection = "erreur connect";
    	 MainActivity.ResultatConnection.concat(e.getMessage());
         }
         MainActivity.ResultatConnection = "après connect";
         // Get input and output stream references
         in = telnet.getInputStream();
         MainActivity.ResultatConnection = " in = telnet.getInputStream();";
     
         try{
    	 out = new PrintStream(telnet.getOutputStream());
         } catch ( NullPointerException e){
    		MainActivity.ResultatConnection = "NullPointerException outputstream";
    		MainActivity.ResultatConnection = MainActivity.ResultatConnection.concat(e.getMessage());
         }
     MainActivity.ResultatConnection = " out = new PrintStream(telnet.getOutputStream());";
     readUntil("Login username: ");
     MainActivity.ResultatConnection = "apres read until user";
     write(user);
     
     
     
    MainActivity.ResultatConnection = "avant pwd";
    readUntil("Login password: ");
    write(password);
    MainActivity.ResultatConnection = "avant domain";
    readUntil("Domain name: ");
    write("");
     
    MainActivity.ResultatConnection = "après domain";
    // Advance to a prompt
     readUntil(prompt + " ");
     }
    catch (Exception e) {
     e.printStackTrace();
     }
     }
     
    public void su(String password) {
     try {
     write("su");
    readUntil("Password: ");
    write(password);
     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.getBytes());
    out.flush();
    //out.write(value.concat("\n").getBytes());
     //out2.write(value.concat("\n"));
     
    	 out.flush();
     //System.out.println(value);
     }
     catch (Exception e) {
     e.printStackTrace();
    MainActivity.ResultatConnection = "erreur write value = ".concat(value).concat(value.getBytes().toString().concat("\n"));
    MainActivity.ResultatConnection.concat(e.getMessage());
     
     }
     }
     
    public String sendCommand(String command) {
     try {
     write(command);
     return readUntil(prompt + " ");
     }
    catch (Exception e) {
     e.printStackTrace();
    /* MainActivity.ResultatConnection = "erreur Send Commande";
     MainActivity.ResultatConnection.concat(e.getMessage());*/
     }
     return null;
     }
     
     
    	public void disconnect() {
    	 try {
    	 telnet.disconnect();
    	 }
    	 catch (Exception e) {
    	 e.printStackTrace();
    	 }
    		}}


    Dans mon MainActivity j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    package com.example.telnetv2;
     
    import android.os.Bundle;
    import android.app.Activity;
    import android.app.AlertDialog;
    import android.view.Menu;
    import android.widget.EditText;
     
     
    public class MainActivity extends Activity {
     
    	//EditText editText1 = new EditText(R.id.); 
    	//EditText zoneText1 =(EditText) findViewById(R.id.);
    	//public String status = getString(R.string.Status) ; 
    	public String text = "Début\n"; 
    	public static String  ResultatConnection = "";
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        	//TextView vTextView = (TextView)findViewById(R.id.textView1);
        	EditText editText1 =(EditText) findViewById(R.id.editText1);
            text = text.concat("Connecting...\n") ;
            //editText1.setText(R.string.Connecting);
            editText1.setText(text);
            //editText1.setText("connecting");
            //vTextView.setText("Connecting...");
            AutomatedTelnetClient telnet = new AutomatedTelnetClient("10.100.50.70", "s36", "s36") ;
            //AutomatedTelnetClient telnet = new AutomatedTelnetClient("127.0.0.1", "telnet", "telnet") ;
     
            //telnet.sendCommand("ps -ef ");
            //text = text.concat("Connected.\n") ;
            text = text.concat(ResultatConnection) ;
            editText1.setText(text);
            //telnet.sendCommand("ps -ef ");
            telnet.sendCommand("copy etik.txt lpt1");
            text = text.concat("commande envoyée") ;
            editText1.setText(text);
            telnet.disconnect();
            text = text.concat("Disconnected. \n") ;
            editText1.setText(text);
    /*      AlertDialog alertDialog;
            alertDialog = new AlertDialog.Builder(this).create();
            alertDialog.setTitle("debug");
            alertDialog.setMessage("Avant login");
            alertDialog.show();*/
        }
     
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
     
    }

    Mon but c'est de lancer la commande "copy etik.txt lpt1" pour tester et si celà fonctionne j'ai d'autres commandes mais bon faut passer la premiere étape.

    Je veux juste préciser une chose, c'est mon premier code java! donc je n'ai pas encore (sans aucun doute) les bons réflexes et du coup l'erreure est peut etre évidente....

    en résultat j'ai :
    Nom : erreur telnet.GIF
Affichages : 104
Taille : 14,5 Ko

    Merci d'avance

  3. #3
    Expert confirmé

    Homme Profil pro
    Ingénieur systèmes et réseaux
    Inscrit en
    Février 2007
    Messages
    4 253
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Ingénieur systèmes et réseaux
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Février 2007
    Messages : 4 253
    Billets dans le blog
    3
    Par défaut
    Je pense que tu as un problème de conception d'application.

    Concernant AutomatedTelnetClient:
    Je pense que le contructeur ne devrait pas faire tout cela....
    Une fonction "connect()" semble plus appropriée (d'autant qu'il y a une fonction disconnect() !)
    Ensuite les try/catch me semblent étranges....
    Là, tels qu'ils sont ils disent:
    Si il y a une exception sur un telnet.addOptionHandler(...); c'est pas grave on peut continuer quand même....
    Si il y a une exception sur telnet.connect(server, port); c'est pas grave on peut continuer quand même...
    Si il y a une exception sur out = new PrintStream(telnet.getOutputStream()); c'est pas grave on peut continuer quand même...
    Bizarre non ?
    De plus je suis très étonné de voir des fonctions de communication (réseau) qui n'envoient aucune exception (au minimum une IOException est obligatoire !!!)

    Au passage, un catch sur un NullPointerException (runtime) veut dire qu'on a foiré un truc quelque part....


    Je pense que le gros try/catch autour est "logique" pour TRADUIRE une exception éventuelle (par exemple en TelnetClientException):
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
     
    public class AutomatedTelnetClient {
       private String server;
       private String user;
       private String password;
     
       public AutomatedTelnetClient(String server, String user, String password) {
           this.server = server;
           this.user = user;
           this.password = password;
       }
     
       public void connect() throws IOException
       {
           String state = "start";
           try {
              ... tout le code sans try/catch ou on met à jour le 'state'...
           } catch (IOException ioe) {
              throw ioe; // on garde l'IOException inchangée...
           } catch (Exception ex) {
              // on traduit en IOException (en conservant la cause).
              throw new IOException("Couldn't connect ("+state+")",ex);
           }
       }
     
    }
    Ensuite, quand on fait disparaitre une exception (catch sans throw), il *FAUT* toujours la loguer en entier. Dans Android c'est:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
    } catch (Exception ex) {
        Log.e("AutomatedTelnetClient","Exception à tel ou tel endroit",ex);
    }
    Déjà le logcat aura une jolie trace de l'exception avec toutes les raisons qui on fait que cette exception a eu lieu.


    Concernant l'activité:
    Le onCreate() de l'activité fait tout un tas de trucs, à chaque fois appelant editText.setText() un seul suffit à la fin.... Tant que la fonction onCreate() n'est pas terminée, l'activité n'est pas affichée !
    D'ailleurs elle fait directement des appels à la classe AutomatedTelnetClient qui risquent d'être potentiellement longs (réseau), les fonctions de l'activité n'en ont PAS LE DROIT. Ce sera même vérifié par le système sous android 3.0+ (NetworkOnMainThreadException).
    Il faut passer par des tâches asynchrones pour réaliser les opérations d'entrée/sortie.

    Je vois d'autre part l'utilisation de l'adresse IP 10.100.50.70....
    C'est impossible... sauf si l'appareil est connecté en WiFi directement à ce réseau.
    Dans le cas d'un émulateur, c'est d'autant plus impossible que le seul réseau accessible à celui-ci est le réseau privé local (entre la machine hôte et l'émulateur) en 10.0.2.x

  4. #4
    Membre régulier
    Homme Profil pro
    technicien a tout faire...
    Inscrit en
    Janvier 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : technicien a tout faire...
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Janvier 2013
    Messages : 7
    Par défaut
    Merci bcp nicroman.
    Je vais retravailler sur le code avec tes conseils et reposter tout ça.
    Sinon pour mon null exception cetait a cause des droits sur le wifi d'android 2.3.3....
    cest un ami qui ma indiqué ce point
    Pareil je posterais ce qu'il ma rajouté si sa peut e'n aider certains.
    et du coup jarrive bien a taper sur 10.100.50.70, mais je precise, cest la machine hote de ma vm android... peut etre estce pour cela.
    Encore merci

  5. #5
    Membre régulier
    Homme Profil pro
    technicien a tout faire...
    Inscrit en
    Janvier 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : technicien a tout faire...
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Janvier 2013
    Messages : 7
    Par défaut
    Bon,
    j'ai fait un peu de ménage......lol beaucoup mais j'ai bien aprécié ton aide car je viens de me rappeler un peu mes cours de dev et donc des exceptions....

    J'ai refait un peu la classe :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    package com.example.telnetv2;
     
     
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.PrintStream;
     
    import org.apache.commons.net.telnet.EchoOptionHandler;
    import org.apache.commons.net.telnet.InvalidTelnetOptionException;
    import org.apache.commons.net.telnet.SuppressGAOptionHandler;
    import org.apache.commons.net.telnet.TelnetClient;
    import org.apache.commons.net.telnet.TerminalTypeOptionHandler;
     
    import android.util.Log;
     
     
     
     
     
    	  public class AutomatedTelnetClient {
    		   private String server;
    		   private String user;
    		   private String password;
    		   private TelnetClient telnet = new TelnetClient();
    		   private InputStream in;
    		   private PrintStream out;
    		   private String prompt = "^]";
     
     
     
    		   public AutomatedTelnetClient(String server, String user, String password) {
    		       this.server = server;
    		       this.user = user;
    		       this.password = password;
    		   }
     
    		   public void connect() throws IOException
    		   {
    		       String state = "start\n";
    		       try {
    		          //... tout le code sans try/catch ou on met à jour le 'state'...
     
    		    	 TerminalTypeOptionHandler ttopt = new TerminalTypeOptionHandler("VT100", false, false, true, false);
    				 EchoOptionHandler echoopt = new EchoOptionHandler(true, false, true, false);
    				 SuppressGAOptionHandler gaopt = new SuppressGAOptionHandler(true, true, true, true);
    			     telnet.addOptionHandler(ttopt);
    				 telnet.addOptionHandler(echoopt);
    				 telnet.addOptionHandler(gaopt);
    				 state.concat("params ok \n");
    				 telnet.connect( server, 23 );
    				 state.concat("Connect ok \n");
    				 in = telnet.getInputStream();
    				 state.concat("IN ok \n");
    				 out = new PrintStream( telnet.getOutputStream() );
    				 state.concat("OUT ok \n");
    				 readUntil( "login: " );
    				 write( user );
    				 state.concat("LOGIN ok \n");
    				 readUntil( "word: " );
    				 write( password );
    				 state.concat("PASS ok \n");
    				 readUntil( "domain: " );
    				 write(" ");
    				 readUntil( prompt+"" );
    				 state.concat("Connection successfull\n");
     
    		       } catch (IOException ioe) {
    		          throw ioe; // on garde l'IOException inchangée...
    		       } catch (Exception ex) {
    		          // on traduit en IOException (en conservant la cause).
    		          throw new IOException("Couldn't connect ("+state+")",ex);
    		       }
    		   }
     
    	 public String readUntil( String pattern ) {
    	   try {
    		 char lastChar = pattern.charAt( pattern.length() - 1 );
    		 StringBuffer sb = new StringBuffer();
    		 @SuppressWarnings("unused")
    		boolean found = false;
    		 char ch = ( char )in.read();
    		 Log.d("Read","entree While");
    		 while( true ) {
     
    		  System.out.print( ch );
    		 Log.d("Read","in = " + ch);
    		  sb.append( ch );
    		  if( ch == lastChar ) {
    		    if( sb.toString().endsWith( pattern ) ) {
    		    	Log.d("Read","sortie While");
    		    	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 );
    		 Log.d("Write",value);
    	   }
    	   catch( Exception e ) {
    		 e.printStackTrace();
    	   }
    	  }
     
    	  public void sendCommand( String command ) {
    	   try {
    		 write( command );
     
    		 readUntil( prompt +"" );
     
    	   }
    	   catch( Exception e ) {
    		 e.printStackTrace();
    	   }
    	  }
     
    	  public void disconnect() {
    	   try {
    		 telnet.disconnect();
    	   }
    	   catch( Exception e ) {
    		 e.printStackTrace();
    	   }
    	  }
    	}
    Et mon activité :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    package com.example.telnetv2;
     
    import java.io.IOException;
     
    import android.app.Activity;
    import android.os.Bundle;
    import android.util.Log;
    import android.view.Menu;
    import android.widget.EditText;
     
     
    public class MainActivity extends Activity {
     
    	//EditText editText1 = new EditText(R.id.); 
    	//EditText zoneText1 =(EditText) findViewById(R.id.);
    	//public String status = getString(R.string.Status) ; 
    	public String text = "Début\n"; 
    	public static String  ResultatConnection = "";
     
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
        	EditText editText1 =(EditText) findViewById(R.id.editText1);
            text = text.concat("Connecting...\n") ;
            AutomatedTelnetClient telnet = new AutomatedTelnetClient("10.100.50.70", "s36", "s37") ;
            try {
    			telnet.connect();
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			 Log.d("Connect","Connection KO",e);
     
    		}
            //AutomatedTelnetClient telnet = new AutomatedTelnetClient("127.0.0.1", "telnet", "telnet") ;
            telnet.sendCommand("copy etik.txt lpt1");
            text = text.concat("commande envoyée.\n") ;
            telnet.disconnect();
            text = text.concat("Disconnected. \n") ;
            editText1.setText(text);
        }
     
        @Override
        public boolean onCreateOptionsMenu(Menu menu) {
            // Inflate the menu; this adds items to the action bar if it is present.
            getMenuInflater().inflate(R.menu.activity_main, menu);
            return true;
        }
     
    }
    Celà m'à l'air de fonctionner sauf que je dois oublier quelque chose dans le protocole telnet.
    Lorsque je log le read du IN je retrouve ce que j'écris dans le out....
    Le poste le log des fois que...
    -------------------------------------------------
    01-04 09:18:50.990: D/Read(369): entree While
    01-04 09:18:50.990: D/Read(369): in = W
    01-04 09:18:50.992: D/Read(369): in = e
    01-04 09:18:50.992: D/Read(369): in = l
    01-04 09:18:50.992: D/Read(369): in = c
    01-04 09:18:50.992: D/Read(369): in = o
    01-04 09:18:50.992: D/Read(369): in = m
    01-04 09:18:50.992: D/Read(369): in = e
    01-04 09:18:50.992: D/Read(369): in =
    01-04 09:18:50.992: D/Read(369): in = t
    01-04 09:18:51.002: D/Read(369): in = o
    01-04 09:18:51.002: D/Read(369): in =
    01-04 09:18:51.002: D/Read(369): in = M
    01-04 09:18:51.002: D/Read(369): in = i
    01-04 09:18:51.002: D/Read(369): in = c
    01-04 09:18:51.002: D/Read(369): in = r
    01-04 09:18:51.002: D/Read(369): in = o
    01-04 09:18:51.002: D/Read(369): in = s
    01-04 09:18:51.011: D/Read(369): in = o
    01-04 09:18:51.011: D/Read(369): in = f
    01-04 09:18:51.011: D/Read(369): in = t
    01-04 09:18:51.011: D/Read(369): in =
    01-04 09:18:51.011: D/Read(369): in = T
    01-04 09:18:51.011: D/Read(369): in = e
    01-04 09:18:51.011: D/Read(369): in = l
    01-04 09:18:51.011: D/Read(369): in = n
    01-04 09:18:51.022: D/Read(369): in = e
    01-04 09:18:51.022: D/Read(369): in = t
    01-04 09:18:51.022: D/Read(369): in =
    01-04 09:18:51.022: D/Read(369): in = S
    01-04 09:18:51.022: D/Read(369): in = e
    01-04 09:18:51.022: D/Read(369): in = r
    01-04 09:18:51.022: D/Read(369): in = v
    01-04 09:18:51.022: D/Read(369): in = i
    01-04 09:18:51.022: D/Read(369): in = c
    01-04 09:18:51.022: D/Read(369): in = e
    01-04 09:18:51.022: D/Read(369): in =
    01-04 09:18:51.032: D/Read(369): in =

    01-04 09:18:51.032: I/System.out(369): Welcome to Microsoft Telnet Service

    01-04 09:18:51.032: D/Read(369): in =
    01-04 09:18:51.032: D/Read(369): in =
    01-04 09:18:51.032: D/Read(369): in =

    01-04 09:18:51.032: D/Read(369): in = l
    01-04 09:18:51.032: D/Read(369): in = o
    01-04 09:18:51.032: D/Read(369): in = g
    01-04 09:18:51.032: D/Read(369): in = i
    01-04 09:18:51.043: D/Read(369): in = n
    01-04 09:18:51.043: D/Read(369): in = :
    01-04 09:18:51.043: D/Read(369): in =
    01-04 09:18:51.043: D/Read(369): sortie While
    01-04 09:18:51.043: I/System.out(369):
    login: s36
    01-04 09:18:51.043: D/Write(369): s36
    01-04 09:18:51.043: D/Read(369): entree While
    01-04 09:18:51.053: D/Read(369): in = s
    01-04 09:18:51.053: D/Read(369): in = 3
    01-04 09:18:51.053: D/Read(369): in = 6
    01-04 09:18:55.453: D/dalvikvm(135): GC_EXPLICIT freed 57K, 51% free 2922K/5895K, external 4672K/5329K, paused 54ms
    01-04 09:19:05.192: D/dalvikvm(233): GC_EXPLICIT freed 499K, 55% free 2599K/5703K, external 1625K/2137K, paused 57ms
    01-04 09:19:10.282: D/dalvikvm(302): GC_EXPLICIT freed 8K, 54% free 2543K/5511K, external 1625K/2137K, paused 87ms

    ------------------------------------------------
    Il relis ce que je lui indique et attend certainement que je lui envoi quelque chose mais même avec \n pour le write du "s36", celà ne fait rien.

    Je pense que celà vient du paramétrage telnet soit coté serveur soit coté client. J'ai regardé du coté de vt100 mais je n'ai pas de doc probante.

    Je ne sais pas quel est mon "prompt" non plus. Est-ce le "Ctrl +$"? ou ">" ?

  6. #6
    Membre régulier
    Homme Profil pro
    technicien a tout faire...
    Inscrit en
    Janvier 2013
    Messages
    7
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : technicien a tout faire...
    Secteur : Agroalimentaire - Agriculture

    Informations forums :
    Inscription : Janvier 2013
    Messages : 7
    Par défaut
    C'est bon!!


    En faite il fallait pas mettre \n mais \r....

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     AutomatedTelnetClient telnet = new AutomatedTelnetClient("10.100.50.70", "s36\r", "s37\r")
    ceci est une commande test, je vais faire ça proprement deriere...

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Problème de connexion Telnet via "Apache Commons Net"
    Par le_misterioso dans le forum Général Java
    Réponses: 1
    Dernier message: 23/02/2011, 21h39
  2. [DisplayTag] installation org/apache/commons/lang/UnhandledException
    Par itr dans le forum Taglibs
    Réponses: 7
    Dernier message: 26/10/2009, 17h29
  3. Réponses: 3
    Dernier message: 08/05/2006, 23h31
  4. [DisplayTag] java.lang.NoClassDefFoundError: org/apache/commons/lang/UnhandledException
    Par MAJIK_ENIS dans le forum Taglibs
    Réponses: 18
    Dernier message: 06/04/2006, 10h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo