GNU Info
Info Node: (python2.1-lib.info)Telnet Example
(python2.1-lib.info)Telnet Example
Telnet Example
--------------
This manual section was written by Peter Funk <pf@artcom-gmbh.de>.
A simple example illustrating typical use:
import getpass
import sys
import telnetlib
HOST = "localhost"
user = raw_input("Enter your remote account: ")
password = getpass.getpass()
tn = telnetlib.Telnet(HOST)
tn.read_until("login: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("ls\n")
tn.write("exit\n")
print tn.read_all()
automatically generated by info2www version 1.2.2.9
|