Sending Through ^] Through telnetlib
Mahrt, Dallas
dallasm at aiinet.com
Fri Jan 23 14:04:03 EST 2004
> "John Abel" <john.abel at pa.press.net> wrote in message
> news:mailman.687.1074866920.12720.python-> list at python.org...
> >
> I have written a script that makes a
> telnet connection, runs various
> > commands, and returns the output. That was the easy bit :)
> However, to
> > close the session, I need to send ^] followed by quit. I've tried
> > sending chr(29), which is the ascii equivalent, but that
> doesn't seem to
> > work. Is there something I'm missing?
> >
> > Any pointers would be much appreciated.
> >
> > Thanks
> >
> > J
> >
>
FYI the telnetlib (as of 2.2.1, not sure past that) does not support all
telenet commands. If you want to send a special command, you need to access
the raw socket and send the extened options list character and the command
character.
Ex: to send a Telnet BREAK
telnetCon.get_socket().send(chr(255)+chr(243))
So maybe trying
telnetCon.get_socket().send(chr(255)+chr(29))
Will work fo you?
---
Dallas S. Mahrt>
More information about the Python-list
mailing list