I need to send some special keystrokes and am unsure of how to do it.
I need to send Ctrl + Q followed by Ctrl + A to a terminal (I'm using Paramiko).
i have tried
shell = client.invoke_shell() shell.send(chr(10)) time.sleep(5) shell.send(chr(13)) shell.send('\x11') shell.send('\x01') print 'i tried'
I can see the two returns go in successfully, but then nothing, it doesnt quit the picocom (also to note i have it the wrong way round, its expecting ctrl+a, then ctrl+q)
if it helps this is the device http://www.cisco.com/c/en/us/td/docs/routers/access/interfaces/eesm/software/configuration/guide/4451_config.html#pgfId-1069760
as you can see at step 2
Step 2 Exit the session from the switch, press Ctrl-a and Ctrl-q from your keyboard: Switch# <type ^a^q> Thanks for using picocom Router#
2 Answers
Answers 1
Just as assumption: maybe pseudoterminal would help
import paramiko client = paramiko.SSHClient() client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) client.connect(...) channel = сlient.get_transport().open_session() channel.get_pty() channel.settimeout(5) channel.exec_command('\x11\x01')
Answers 2
Pressing Ctrl + key is actually a "user-friendly" way to enter ASCII control characters. The combination Ctrl + H, for example, is equivalent to entering a backspace. This site lists the ASCII control characters associated with their key combinations, so Ctrl+Q, Ctrl+A is equivalent to sending the string "\x11\x01"
through the paramiko Channel:
channel = client.invoke_shell() channel.send('\x11\x01')
0 comments:
Post a Comment