Telnetlib - send brk
Patrick Vrijlandt
p.vrijlandt at aig.azn.nl
Tue Oct 16 03:12:47 EDT 2001
"Donnie Miller" <drmiller at pldi.net>
> I've been trying the telnetlib library rather than using expect
> scripts as I have done in the past. I have had success with it up until
> the point where I needed to send a "break" sequence to a server. I have
> searched all over various lists and google, but have not found
> anything. Does anyone have any idea of how to do this?
Telnetlib provides no way to send telnet control characters:
IAC = chr(255) # Interpret As Command
DONT = chr(254) #
DO = chr(253) #
WONT = chr(252) #
WILL = chr(251) #
SB = chr(250) # Subnegotiation Begin
GA = chr(249) # Go Ahead
EL = chr(248) # Erase Line
EC = chr(247) # Erase Char
AYT = chr(246) # Are You There
AO = chr(245) # Abort Output
IP = chr(244) # Interrupt Process
BRK = chr(243) # NVT-Break
DM = chr(242) # Data Mark
NOP = chr(241) # No Operation
SE = chr(240) # Subnegotiation End
So you have to patch the write method, originally:
def write(self, buffer):
if IAC in buffer:
buffer = buffer.replace(IAC, IAC+IAC)
self.msg("send %s", `buffer`)
self.sock.send(buffer)
so that BRK (and the other telnet commands) also is/are prepended by an IAC
character.
More information about the Python-list
mailing list