Yurttas/PL/SL/python/docs/core-python-programming/doc/20/lib/telnet-example.html

Revision as of 20:01, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<div class="navigation"> {| width="100%" cellspacing="2" align="center" | yurttas/PL/SL/python/docs/core-python-programming/doc/20/lib/telnet-objects.html|[[Image:yurtt...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


11.11.2 Telnet Example

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()

See About this document... for information on suggesting changes.