Sending keys with escape sequence e.g up key appears as ^[[A in terminal

10 views
Skip to first unread message

Vinode Singh Ujlain

unread,
Oct 5, 2023, 4:58:46 AM10/5/23
to asyncssh-users
I am new to the group adn was searching if my question has been addressed prior , didn't find any. Please look at the below code (a simple ssh client connected to ssh server ). Commands fired work interactively , however when a escape key is pressed , it appears as it is example up key when pressed appears as ^[[A , it should ideally get an item from history. How do I correct this ? or rather , this is a problem with every ssh client I tried , how do I handle keys with escape sequence ?

Last login: Thu Oct  5 13:44:23 2023 from 127.0.0.1
uzi@uzi:~$ ^[[A

import asyncio, asyncssh, sys

# term_type = [ xterm , vt100] - tested both
async def run_client():
async with asyncssh.connect('localhost', username="CCCC", password='XXSD') as conn:
await conn.run(term_type='vt100', stdin=sys.stdin,
stdout=sys.stdout, stderr=sys.stderr)

try:
asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
sys.exit('SSH connection failed: ' + str(exc))
Reply all
Reply to author
Forward
0 new messages