Vega strike Python Modules doc  0.5.1
Documentation of the " Modules " folder of Vega strike
 All Data Structures Namespaces Files Functions Variables
telnetlib Namespace Reference

Data Structures

class  Telnet
 

Functions

def test
 

Variables

list __all__ = ["Telnet"]
 
int DEBUGLEVEL = 0
 
int TELNET_PORT = 23
 
tuple IAC = chr(255)
 
tuple DONT = chr(254)
 
tuple DO = chr(253)
 
tuple WONT = chr(252)
 
tuple WILL = chr(251)
 
tuple theNULL = chr(0)
 
tuple BINARY = chr(0)
 
tuple ECHO = chr(1)
 
tuple RCP = chr(2)
 
tuple SGA = chr(3)
 
tuple NAMS = chr(4)
 
tuple STATUS = chr(5)
 
tuple TM = chr(6)
 
tuple RCTE = chr(7)
 
tuple NAOL = chr(8)
 
tuple NAOP = chr(9)
 
tuple NAOCRD = chr(10)
 
tuple NAOHTS = chr(11)
 
tuple NAOHTD = chr(12)
 
tuple NAOFFD = chr(13)
 
tuple NAOVTS = chr(14)
 
tuple NAOVTD = chr(15)
 
tuple NAOLFD = chr(16)
 
tuple XASCII = chr(17)
 
tuple LOGOUT = chr(18)
 
tuple BM = chr(19)
 
tuple DET = chr(20)
 
tuple SUPDUP = chr(21)
 
tuple SUPDUPOUTPUT = chr(22)
 
tuple SNDLOC = chr(23)
 
tuple TTYPE = chr(24)
 
tuple EOR = chr(25)
 
tuple TUID = chr(26)
 
tuple OUTMRK = chr(27)
 
tuple TTYLOC = chr(28)
 
tuple VT3270REGIME = chr(29)
 
tuple X3PAD = chr(30)
 
tuple NAWS = chr(31)
 
tuple TSPEED = chr(32)
 
tuple LFLOW = chr(33)
 
tuple LINEMODE = chr(34)
 
tuple XDISPLOC = chr(35)
 
tuple OLD_ENVIRON = chr(36)
 
tuple AUTHENTICATION = chr(37)
 
tuple ENCRYPT = chr(38)
 
tuple NEW_ENVIRON = chr(39)
 
tuple TN3270E = chr(40)
 
tuple XAUTH = chr(41)
 
tuple CHARSET = chr(42)
 
tuple RSP = chr(43)
 
tuple COM_PORT_OPTION = chr(44)
 
tuple SUPPRESS_LOCAL_ECHO = chr(45)
 
tuple TLS = chr(46)
 
tuple KERMIT = chr(47)
 
tuple SEND_URL = chr(48)
 
tuple FORWARD_X = chr(49)
 
tuple PRAGMA_LOGON = chr(138)
 
tuple SSPI_LOGON = chr(139)
 
tuple PRAGMA_HEARTBEAT = chr(140)
 
tuple EXOPL = chr(255)
 

Detailed Description

TELNET client class.

Based on RFC 854: TELNET Protocol Specification, by J. Postel and
J. Reynolds

Example:

>>> from telnetlib import Telnet
>>> tn = Telnet('www.python.org', 79)   # connect to finger port
>>> tn.write('guido\r\n')
>>> print tn.read_all()
Login       Name               TTY         Idle    When    Where
guido    Guido van Rossum      pts/2        <Dec  2 11:10> snag.cnri.reston..

>>>

Note that read_all() won't read until eof -- it just reads some data
-- but it guarantees to read at least one byte unless EOF is hit.

It is possible to pass a Telnet object to select.select() in order to
wait until more data is available.  Note that in this case,
read_eager() may return '' even if there was data on the socket,
because the protocol negotiation may have eaten the data.  This is why
EOFError is needed in some cases to distinguish between "no data" and
"connection closed" (since the socket also appears ready for reading
when it is closed).

Bugs:
- may hang when connection is slow in the middle of an IAC sequence

To do:
- option negotiation
- timeout should be intrinsic to the connection object instead of an
  option on one of the read calls only

Function Documentation

def telnetlib.test ( )
Test program for telnetlib.

Usage: python telnetlib.py [-d] ... [host [port]]

Default host is localhost; default port is 23.

Definition at line 564 of file telnetlib.py.

565 def test():
566  """Test program for telnetlib.
567 
568  Usage: python telnetlib.py [-d] ... [host [port]]
569 
570  Default host is localhost; default port is 23.
571 
572  """
573  debuglevel = 0
574  while sys.argv[1:] and sys.argv[1] == '-d':
575  debuglevel = debuglevel+1
576  del sys.argv[1]
577  host = 'localhost'
578  if sys.argv[1:]:
579  host = sys.argv[1]
580  port = 0
581  if sys.argv[2:]:
582  portstr = sys.argv[2]
583  try:
584  port = int(portstr)
585  except ValueError:
586  port = socket.getservbyname(portstr, 'tcp')
587  tn = Telnet()
588  tn.set_debuglevel(debuglevel)
589  tn.open(host, port)
590  tn.interact()
591  tn.close()

Variable Documentation

list __all__ = ["Telnet"]

Definition at line 44 of file telnetlib.py.

tuple AUTHENTICATION = chr(37)

Definition at line 99 of file telnetlib.py.

tuple BINARY = chr(0)

Definition at line 62 of file telnetlib.py.

tuple BM = chr(19)

Definition at line 81 of file telnetlib.py.

tuple CHARSET = chr(42)

Definition at line 108 of file telnetlib.py.

tuple COM_PORT_OPTION = chr(44)

Definition at line 110 of file telnetlib.py.

int DEBUGLEVEL = 0

Definition at line 47 of file telnetlib.py.

tuple DET = chr(20)

Definition at line 82 of file telnetlib.py.

tuple DO = chr(253)

Definition at line 55 of file telnetlib.py.

tuple DONT = chr(254)

Definition at line 54 of file telnetlib.py.

tuple ECHO = chr(1)

Definition at line 63 of file telnetlib.py.

tuple ENCRYPT = chr(38)

Definition at line 100 of file telnetlib.py.

tuple EOR = chr(25)

Definition at line 87 of file telnetlib.py.

tuple EXOPL = chr(255)

Definition at line 119 of file telnetlib.py.

tuple FORWARD_X = chr(49)

Definition at line 115 of file telnetlib.py.

tuple IAC = chr(255)

Definition at line 53 of file telnetlib.py.

tuple KERMIT = chr(47)

Definition at line 113 of file telnetlib.py.

tuple LFLOW = chr(33)

Definition at line 95 of file telnetlib.py.

tuple LINEMODE = chr(34)

Definition at line 96 of file telnetlib.py.

tuple LOGOUT = chr(18)

Definition at line 80 of file telnetlib.py.

tuple NAMS = chr(4)

Definition at line 66 of file telnetlib.py.

tuple NAOCRD = chr(10)

Definition at line 72 of file telnetlib.py.

tuple NAOFFD = chr(13)

Definition at line 75 of file telnetlib.py.

tuple NAOHTD = chr(12)

Definition at line 74 of file telnetlib.py.

tuple NAOHTS = chr(11)

Definition at line 73 of file telnetlib.py.

tuple NAOL = chr(8)

Definition at line 70 of file telnetlib.py.

tuple NAOLFD = chr(16)

Definition at line 78 of file telnetlib.py.

tuple NAOP = chr(9)

Definition at line 71 of file telnetlib.py.

tuple NAOVTD = chr(15)

Definition at line 77 of file telnetlib.py.

tuple NAOVTS = chr(14)

Definition at line 76 of file telnetlib.py.

tuple NAWS = chr(31)

Definition at line 93 of file telnetlib.py.

tuple NEW_ENVIRON = chr(39)

Definition at line 101 of file telnetlib.py.

tuple OLD_ENVIRON = chr(36)

Definition at line 98 of file telnetlib.py.

tuple OUTMRK = chr(27)

Definition at line 89 of file telnetlib.py.

tuple PRAGMA_HEARTBEAT = chr(140)

Definition at line 118 of file telnetlib.py.

tuple PRAGMA_LOGON = chr(138)

Definition at line 116 of file telnetlib.py.

tuple RCP = chr(2)

Definition at line 64 of file telnetlib.py.

tuple RCTE = chr(7)

Definition at line 69 of file telnetlib.py.

tuple RSP = chr(43)

Definition at line 109 of file telnetlib.py.

tuple SEND_URL = chr(48)

Definition at line 114 of file telnetlib.py.

tuple SGA = chr(3)

Definition at line 65 of file telnetlib.py.

tuple SNDLOC = chr(23)

Definition at line 85 of file telnetlib.py.

tuple SSPI_LOGON = chr(139)

Definition at line 117 of file telnetlib.py.

tuple STATUS = chr(5)

Definition at line 67 of file telnetlib.py.

tuple SUPDUP = chr(21)

Definition at line 83 of file telnetlib.py.

tuple SUPDUPOUTPUT = chr(22)

Definition at line 84 of file telnetlib.py.

tuple SUPPRESS_LOCAL_ECHO = chr(45)

Definition at line 111 of file telnetlib.py.

int TELNET_PORT = 23

Definition at line 50 of file telnetlib.py.

tuple theNULL = chr(0)

Definition at line 58 of file telnetlib.py.

tuple TLS = chr(46)

Definition at line 112 of file telnetlib.py.

tuple TM = chr(6)

Definition at line 68 of file telnetlib.py.

tuple TN3270E = chr(40)

Definition at line 106 of file telnetlib.py.

tuple TSPEED = chr(32)

Definition at line 94 of file telnetlib.py.

tuple TTYLOC = chr(28)

Definition at line 90 of file telnetlib.py.

tuple TTYPE = chr(24)

Definition at line 86 of file telnetlib.py.

tuple TUID = chr(26)

Definition at line 88 of file telnetlib.py.

tuple VT3270REGIME = chr(29)

Definition at line 91 of file telnetlib.py.

tuple WILL = chr(251)

Definition at line 57 of file telnetlib.py.

tuple WONT = chr(252)

Definition at line 56 of file telnetlib.py.

tuple X3PAD = chr(30)

Definition at line 92 of file telnetlib.py.

tuple XASCII = chr(17)

Definition at line 79 of file telnetlib.py.

tuple XAUTH = chr(41)

Definition at line 107 of file telnetlib.py.

tuple XDISPLOC = chr(35)

Definition at line 97 of file telnetlib.py.