4

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?

Dhruv Patel
  • 426
  • 3
  • 9
  • 19

2 Answers2

9

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

tn.write('\x03')
Hussain Shabbir
  • 14,801
  • 5
  • 40
  • 56
6
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)
Iacchus
  • 2,671
  • 2
  • 29
  • 24