[Tutor] Telnet and special characters

Luke Paireepinart rabidpoobear at gmail.com
Tue Feb 27 20:56:53 CET 2007


Chris Hallman wrote:
>
> Is it possible to send a F1 "character" over a telnet connection? I've 
> searched but I can't find a solution. I've tried SendKeys 
> <http://www.rutherfurd.net/python/sendkeys/> and other methods, but I 
> can't get it to work.
>
> import telnetlib
>
> pswd = "***"
> host = "***"
> tn = telnetlib.Telnet(host)
> tn.read_until("password:", 7)
> tn.write(pswd + "\n")
> tn.write(chr(27)) # ESC
> tn.write (chr(78)) # Shift N
> tn.write(chr(25)) # Down arrow
You could have a special sequence of characters that wouldn't normally 
be used, like \1\1\2\3\1\2\4,
and if the server receives this, you can use pyHook or something to 
generate a keypress on the other end.
It seems to me that the function keys would have a value too.
I don't have time to investigate the matter further currently, I'll try 
to look into it later.
-Luke
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>   



More information about the Tutor mailing list