0

I am working with network equipment, i writing a program that uses asyncssh to do ssh to network device.

The network device sends sometimes updates via the session using broadcast. What i am trying to do is to make a listener that listens to the stdout, and still can get user inputs (probably will be some sort of rest api functions).

Is it possible to do so?

Klutz
  • 5
  • 1
  • 2

1 Answers1

1

This stack overflow answer shows you how to listen to stdin async:

https://stackoverflow.com/a/35514777/10840818

Write some code. What are you trying to do? The following is the example from the asyncSSH docs. Is your question about asyncSSH or something else?

import asyncio, asyncssh, sys

async def run_client():
    async with asyncssh.connect('localhost') as conn:
        result = await conn.run('echo "Hello!"', check=True)
        print(result.stdout, end='')

try:
    asyncio.get_event_loop().run_until_complete(run_client())
except (OSError, asyncssh.Error) as exc:
    sys.exit('SSH connection failed: ' + str(exc))

If you need a server process look at sanic and set up a rest API instead of stdin for communicating.

MarkReedZ
  • 1,421
  • 4
  • 10