Un exemple simple illustrant un usage typique:
import getpass
import sys
import telnetlib
HOTE = "localhost"
utilisateur = raw_input("Entrez votre compre distant: ")
motdepasse = getpass.getpass()
tn = telnetlib.Telnet(HOTE)
tn.read_until("login: ")
tn.write(utilisateur + "\n")
if motdepasse:
tn.read_until("Password: ")
tn.write(motdepasse + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()