parallelisation telnetlib

parallelisation telnetlib - Python - Programmation

Marsh Posté le 27-01-2011 à 18:24:58    

Messieurs bonjour je cherche à exécuter en même temps 4 sessions telnetlib mais à priori ce n'est pas possible:


class telnetlib.Telnet([host[, port[, timeout]]])¶
 
    Telnet represents a connection to a Telnet server. The instance is initially not connected by default; the open() method must be used to establish a connection. Alternatively, the host name and optional port number can be passed to the constructor, to, in which case the connection to the server will be established before the constructor returns. The optional timeout parameter specifies a timeout in seconds for blocking operations like the connection attempt (if not specified, the global default timeout setting will be used).
 
   Do not reopen an already connected instance.


 
Quelqu'un aurait la solution ou une petite idée à me soumettre ?
Voici le morceau qu'il faudrait que je fasse tourner 4x en même temps:
 

tn = telnetlib.Telnet(sys.argv[1])
tn.read_until("Username: " )
tn.write(usr + "\n" )
if pswd:
    tn.read_until("Password: " )
    tn.write(pswd + "\n" )
tn.write(["ping vrf ", sys.argv[2], " ", sys.argv[5], " ", "size 15000 repeat 5000 \n"])


 
Merci d'avance


Message édité par anapivirtua le 27-01-2011 à 18:25:12

---------------
Si vis pacem, para bellum.
Reply

Marsh Posté le 27-01-2011 à 18:24:58   

Reply

Marsh Posté le 28-01-2011 à 16:42:37    

Pourquoi tu essaies de faire tourner la même chose 4 fois sur le même serveur telnet?


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
Reply

Marsh Posté le 28-01-2011 à 22:06:22    

C'est pour saturer un lien en l’occurrence ! :o


---------------
Si vis pacem, para bellum.
Reply

Marsh Posté le 28-01-2011 à 23:02:04    

OK. Ben faut utiliser threading et ouvrir chaque connection dans son thread.
 
Alternativement, tu peux utiliser multiprocessing (si Python >= 2.6) et ouvrir chaque connection dans son process, ça aura le même effet.


---------------
Stick a parrot in a Call of Duty lobby, and you're gonna get a racist parrot. — Cody
Reply

Marsh Posté le 29-01-2011 à 00:04:50    

ok merci :o


---------------
Si vis pacem, para bellum.
Reply

Sujets relatifs:

Leave a Replay

Make sure you enter the(*)required information where indicate.HTML code is not allowed