How do I send telnetlib control + c command in python

此生再无相见时 提交于 2021-02-07 09:13:08

问题


I am trying to send control + c command in python using telnetlib library. Currently I am doing

tn.write('^]')

But the code above doesn't seem to work. Any clue on What I should use?


回答1:


Try ASCII characters of control+c to the telnet connection below:-

tn.write('\x03')



回答2:


ctrl+a = decimal 1
ctrl+b = decimal 2
ctrl+c = decimal 3

and so on.. to

ctrl+x = decimal 24
ctrl+y = decimal 25
ctrl+z = decimal 26

escape = 27 etc

Still, for those who will need this in the future

Arrow keys are (3 bytes, decimal)

UP ARROW is 27,91,65 (ESC,'[',A)
DOWN ARROW is 27,91,66 (ESC,'[',B)
RIGHT ARROW is 27,91,67 (ESC, '[',C)
LEFT ARROW is 27,91,68 (ESC, '[',D)


来源:https://stackoverflow.com/questions/26183298/how-do-i-send-telnetlib-control-c-command-in-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!