如何在python中发送telnetlib控件+ c命令?

时间:2022-12-16 22:25:12

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

我尝试使用telnetlib库在python中发送控制+ c命令。目前我正在做

tn.write('^]')

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

但是上面的代码似乎没有作用。有什么我应该用的线索吗?

2 个解决方案

#1


6  

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

尝试使用ASCII字符控制+c到telnet连接:-。

tn.write('\x03')

#2


3  

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)

箭头键是(3字节,十进制)

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)

#1


6  

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

尝试使用ASCII字符控制+c到telnet连接:-。

tn.write('\x03')

#2


3  

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)

箭头键是(3字节,十进制)

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)