bonjour à tous
Je viens à nouveau demander de l'aider
Voilà mon interface:

http://www.hostingpics.net/viewer.ph...xionTelnet.png

Donc je viens vous voir car j'ai un petit soucis :
J'utilise un switch hp procurve 2626(à droite sur l'image) et je peux me connecter à harpagon (à gauche de l'image)
donc voilà ensuite je me sers de putty
Je peux me connecter à l'aide de ce logiciel en connexion tel-net au et à harpagon comme le montre l'image
http://www.hostingpics.net/viewer.ph...719Capture.png

Ensuite à l'aide de mon interface , je peux me connecter facilement à harpagon

http://www.hostingpics.net/viewer.ph...98harpagon.png
Et avec le swtich , il me met des erreurs:

http://www.hostingpics.net/viewer.ph...6019216818.png

Donc je vous fournis le code :


Pour ma partie CEquipementRéseau



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
 
using System;
using MinimalisticTelnet;
using TestTelnet;
 
namespace TestTelnet
{
	/// <summary>
	/// Description résumée de CEquipementRéseau.
	/// </summary>
	public class CEquipementRéseau
	{
		// attributs de la classe : 
 
	    protected  string adresseIP;
		protected string login; 
		protected string mot_de_passe; 
 
		private TelnetConnection TC;
 
		// constructeur de la classe: 
 
		public   CEquipementRéseau  (string adresse_IP , string l , string mdp)
		{
			adresseIP=adresse_IP; 
			login=l; 
			mot_de_passe=mdp; 
 
		}
 
		public string Connecter()
		{
			//numero du port
			int NumeroDePort = 23;
			//creation d'un nouvel object TelnetConnection
			TC = new TelnetConnection(adresseIP, NumeroDePort);
			string s = TC.Login(login, mot_de_passe,300);
 
 
 
			//pour test en debugage
			Console.Write(s);
 
			// server output should end with "$" or ">",
			//otherwise the connection failed
			// enlever espaces à la fin
			string prompt = s.TrimEnd();
			// prendre dernier caractère
			prompt = s.Substring(prompt.Length -1,1);
            if (prompt != "$" && prompt != ">" && prompt != "#" )
				throw new Exception("Connection échouée");
 
 
 
			return("Connexion Réussie !!");
		}
 
		public string Deconnecter()
		{
 
			//commande 'logout' permettant de deconnecter la session
			string commande = "logout";
			//variable qui stockera les chaine du serveur
			string str_retour;
 
			//ecris la commande du textbox vers le serveur
			TC.WriteLine(commande);
			//recupere le retour du serveur ds une variable
			str_retour = TC.Read();
 
			//affiche dans une console pas obligatoire
			Console.Write(str_retour);
			return("Déconnecté");
 
		}
 
		public string Executer_Commande(string commande)
		{
			//variable qui stockera les chaine du serveur
			string str_retour;
 
			//ecris la commande du parametre sur le serveur
			TC.WriteLine(commande);
 
			//recupere le retour du serveur dans une variable
			str_retour = TC.Read();
 
			//affiche ds une console pas obligatoire
			Console.Write(str_retour);
 
			return(str_retour);
		}
 
 
 
	}
 
 
 
 
 
 
 
}


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
 
 
// minimalistic telnet implementation
// conceived by Tom Janssens on 2007/06/06  for codeproject
//
// http://www.corebvba.be
 
 
using System;
using System.Text;
using System.Net.Sockets;
 
 
namespace MinimalisticTelnet
{
	enum Verbs 
	{
		WILL = 251,
		WONT = 252,
		DO = 253,
		DONT = 254,
		IAC = 255
	}
 
	enum Options
	{
		SGA = 3
	}
 
	class TelnetConnection
	{
		TcpClient tcpSocket;
 
		int TimeOutMs = 500;
 
		public TelnetConnection(string Hostname, int Port)
		{
			tcpSocket = new TcpClient(Hostname, Port);
		}
 
		public string Login(string Username,string Password,int LoginTimeOutMs)
		{
			int oldTimeOutMs = TimeOutMs;
			TimeOutMs = LoginTimeOutMs;
			string s = Read();
			if (!s.TrimEnd().EndsWith(":"))
				throw new Exception("Failed to connect : no login prompt");
			WriteLine(Username);
 
			s += Read();
			if (!s.TrimEnd().EndsWith(":"))
				throw new Exception("Failed to connect : no password prompt");
			WriteLine(Password);
 
			s += Read();
			TimeOutMs = oldTimeOutMs;
 
			return s;
		}
fomr1.cs

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
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
 
 
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
 
using MinimalisticTelnet;
 
 
using System.Text;
using System.Net.Sockets;
 
namespace TestTelnet
{
	/// <summary>
	/// Description résumée de Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.Label lbAdresseIp;
		private System.Windows.Forms.TextBox textBoxAdresseIp;
		private System.Windows.Forms.Label lbLogin;
		private System.Windows.Forms.TextBox textBoxLogin;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.TextBox textBoxMotDePasse;
		private System.Windows.Forms.Label lbEntrerCommande;
		private System.Windows.Forms.TextBox textBoxEntrerCommande;
		private System.Windows.Forms.Button btConstruire;
		private System.Windows.Forms.Button btConnecter;
		private System.Windows.Forms.Button btDéconnecter;
		private System.Windows.Forms.Button btExécuterCommande;
		private System.Windows.Forms.Label lbTexteRetour;
 
 
		private CEquipementRéseau EquipementRéseau;
		private System.Windows.Forms.Label label2;
		private System.Windows.Forms.TextBox textBoxVLAN;
		/// <summary>
		/// Variable nécessaire au concepteur.
		/// </summary>
		private System.ComponentModel.Container components = null;
 
		public Form1()
		{
			//
			// Requis pour la prise en charge du Concepteur Windows Forms
			//
			InitializeComponent();
 
			//
			// TODO : ajoutez le code du constructeur après l'appel à InitializeComponent
			//
		}
 
		/// <summary>
		/// Nettoyage des ressources utilisées.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
 
		#region Code généré par le Concepteur Windows Form
		/// <summary>
		/// Méthode requise pour la prise en charge du concepteur - ne modifiez pas
		/// le contenu de cette méthode avec l'éditeur de code.
		/// </summary>
		private void InitializeComponent()
		{
            this.lbAdresseIp = new System.Windows.Forms.Label();
            this.textBoxAdresseIp = new System.Windows.Forms.TextBox();
            this.lbLogin = new System.Windows.Forms.Label();
            this.textBoxLogin = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.textBoxMotDePasse = new System.Windows.Forms.TextBox();
            this.lbEntrerCommande = new System.Windows.Forms.Label();
            this.textBoxEntrerCommande = new System.Windows.Forms.TextBox();
            this.btConstruire = new System.Windows.Forms.Button();
            this.btConnecter = new System.Windows.Forms.Button();
            this.btDéconnecter = new System.Windows.Forms.Button();
            this.btExécuterCommande = new System.Windows.Forms.Button();
            this.lbTexteRetour = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.textBoxVLAN = new System.Windows.Forms.TextBox();
            this.SuspendLayout();
            // 
            // lbAdresseIp
            // 
            this.lbAdresseIp.Location = new System.Drawing.Point(8, 16);
            this.lbAdresseIp.Name = "lbAdresseIp";
            this.lbAdresseIp.Size = new System.Drawing.Size(96, 16);
            this.lbAdresseIp.TabIndex = 0;
            this.lbAdresseIp.Text = "Adresse Ip";
            // 
            // textBoxAdresseIp
            // 
            this.textBoxAdresseIp.Location = new System.Drawing.Point(152, 16);
            this.textBoxAdresseIp.Name = "textBoxAdresseIp";
            this.textBoxAdresseIp.Size = new System.Drawing.Size(232, 20);
            this.textBoxAdresseIp.TabIndex = 1;
            this.textBoxAdresseIp.Text = "textBoxAdresseIp";
            // 
            // lbLogin
            // 
            this.lbLogin.Location = new System.Drawing.Point(8, 56);
            this.lbLogin.Name = "lbLogin";
            this.lbLogin.Size = new System.Drawing.Size(88, 16);
            this.lbLogin.TabIndex = 2;
            this.lbLogin.Text = "Login";
            // 
            // textBoxLogin
            // 
            this.textBoxLogin.Location = new System.Drawing.Point(152, 56);
            this.textBoxLogin.Name = "textBoxLogin";
            this.textBoxLogin.Size = new System.Drawing.Size(232, 20);
            this.textBoxLogin.TabIndex = 3;
            this.textBoxLogin.Text = "textBoxLogin";
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(8, 120);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(88, 16);
            this.label1.TabIndex = 4;
            this.label1.Text = "Mot de Passe";
            // 
            // textBoxMotDePasse
            // 
            this.textBoxMotDePasse.Location = new System.Drawing.Point(152, 120);
            this.textBoxMotDePasse.Name = "textBoxMotDePasse";
            this.textBoxMotDePasse.Size = new System.Drawing.Size(232, 20);
            this.textBoxMotDePasse.TabIndex = 5;
            this.textBoxMotDePasse.Text = "textBoxMotDePasse";
            // 
            // lbEntrerCommande
            // 
            this.lbEntrerCommande.Location = new System.Drawing.Point(8, 152);
            this.lbEntrerCommande.Name = "lbEntrerCommande";
            this.lbEntrerCommande.Size = new System.Drawing.Size(112, 16);
            this.lbEntrerCommande.TabIndex = 6;
            this.lbEntrerCommande.Text = "Entrer Commande";
            // 
            // textBoxEntrerCommande
            // 
            this.textBoxEntrerCommande.Location = new System.Drawing.Point(152, 152);
            this.textBoxEntrerCommande.Name = "textBoxEntrerCommande";
            this.textBoxEntrerCommande.Size = new System.Drawing.Size(232, 20);
            this.textBoxEntrerCommande.TabIndex = 7;
            this.textBoxEntrerCommande.Text = "textBoxEntrerCommande";
            // 
            // btConstruire
            // 
            this.btConstruire.Location = new System.Drawing.Point(448, 8);
            this.btConstruire.Name = "btConstruire";
            this.btConstruire.Size = new System.Drawing.Size(136, 24);
            this.btConstruire.TabIndex = 8;
            this.btConstruire.Text = "Construire";
            this.btConstruire.Click += new System.EventHandler(this.btConstruire_Click);
            // 
            // btConnecter
            // 
            this.btConnecter.Location = new System.Drawing.Point(448, 56);
            this.btConnecter.Name = "btConnecter";
            this.btConnecter.Size = new System.Drawing.Size(136, 24);
            this.btConnecter.TabIndex = 9;
            this.btConnecter.Text = "Connecter";
            this.btConnecter.Click += new System.EventHandler(this.btConnecter_Click);
            // 
            // btDéconnecter
            // 
            this.btDéconnecter.Location = new System.Drawing.Point(448, 104);
            this.btDéconnecter.Name = "btDéconnecter";
            this.btDéconnecter.Size = new System.Drawing.Size(136, 24);
            this.btDéconnecter.TabIndex = 10;
            this.btDéconnecter.Text = "Déconnecter";
            this.btDéconnecter.Click += new System.EventHandler(this.btDéconnecter_Click);
            // 
            // btExécuterCommande
            // 
            this.btExécuterCommande.Location = new System.Drawing.Point(448, 152);
            this.btExécuterCommande.Name = "btExécuterCommande";
            this.btExécuterCommande.Size = new System.Drawing.Size(136, 24);
            this.btExécuterCommande.TabIndex = 11;
            this.btExécuterCommande.Text = "Exécuter Commande";
            this.btExécuterCommande.Click += new System.EventHandler(this.btExécuterCommande_Click);
            // 
            // lbTexteRetour
            // 
            this.lbTexteRetour.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(224)))), ((int)(((byte)(224)))), ((int)(((byte)(224)))));
            this.lbTexteRetour.Location = new System.Drawing.Point(8, 192);
            this.lbTexteRetour.Name = "lbTexteRetour";
            this.lbTexteRetour.Size = new System.Drawing.Size(848, 136);
            this.lbTexteRetour.TabIndex = 12;
            this.lbTexteRetour.Text = "TexteRetour";
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(624, 16);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(96, 16);
            this.label2.TabIndex = 13;
            this.label2.Text = "Nom VLAN";
            // 
            // textBoxVLAN
            // 
            this.textBoxVLAN.Location = new System.Drawing.Point(616, 40);
            this.textBoxVLAN.Name = "textBoxVLAN";
            this.textBoxVLAN.Size = new System.Drawing.Size(248, 20);
            this.textBoxVLAN.TabIndex = 14;
            this.textBoxVLAN.Text = "textBox1";
            // 
            // Form1
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(872, 344);
            this.Controls.Add(this.textBoxVLAN);
            this.Controls.Add(this.label2);
            this.Controls.Add(this.lbTexteRetour);
            this.Controls.Add(this.btExécuterCommande);
            this.Controls.Add(this.btDéconnecter);
            this.Controls.Add(this.btConnecter);
            this.Controls.Add(this.btConstruire);
            this.Controls.Add(this.textBoxEntrerCommande);
            this.Controls.Add(this.lbEntrerCommande);
            this.Controls.Add(this.textBoxMotDePasse);
            this.Controls.Add(this.label1);
            this.Controls.Add(this.textBoxLogin);
            this.Controls.Add(this.lbLogin);
            this.Controls.Add(this.textBoxAdresseIp);
            this.Controls.Add(this.lbAdresseIp);
            this.Name = "Form1";
            this.Text = "Form1";
            this.ResumeLayout(false);
            this.PerformLayout();
 
		}
		#endregion
 
		/// <summary>
		/// Point d'entrée principal de l'application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
 
		private void btConstruire_Click(object sender, System.EventArgs e)
		{
 
		}
 
 
 
        //pour le  bouton connecter
		private void btConnecter_Click(object sender, System.EventArgs e)
		{
 
			//adresse Ip
			string adresse_Ip=textBoxAdresseIp.Text; 
			//le login 
			string login = textBoxLogin.Text; 
			//mot de passe 
		    string mdp=textBoxMotDePasse.Text; 
 
			//pour cacher le mot de passe inscrit par l'utilisateur
 
 
		  try
			  {
			//essayer : 
 
			//Créer un nouvel objet CequipementReseaux avec en parametre
			//l'adresse ip distante et l'identifiant.
		    EquipementRéseau = new CEquipementRéseau(adresse_Ip,login,mdp);
 
			//appel la fonction Connecter de la class CequipementReseaux
			lbTexteRetour.Text = EquipementRéseau.Connecter();
		  }
        catch (Exception f)
		{
			  lbTexteRetour.Text=(f.ToString());
		}
 
		}
 
 
		private void btDéconnecter_Click(object sender, System.EventArgs e)
		{
			//appel la fonction Deconnecter de la class CequipementReseaux
			lbTexteRetour.Text = EquipementRéseau.Deconnecter();
 
		}
 
		private void btExécuterCommande_Click(object sender, System.EventArgs e)
		{
			try
			{
				//appel la fonction Executer_Commande de la class CequipementReseaux
				//passage du contenu du label 'commande' en parametre.
				lbTexteRetour.Text = EquipementRéseau.Executer_Commande(textBoxEntrerCommande.Text);				
 
			}
				//affichage d'un message d'erreur si une exception est produite
			catch (Exception f)
			{
				lbTexteRetour.Text = (f.ToString());
			}
 
		}
 
 
 
 
	}
}
Merci d'avnce , je cherche de mon coté
Bonne journée