From e7b5848664c66211c5d1d9c9900dd8e6f6fd3916 Mon Sep 17 00:00:00 2001 From: Sven Sager Date: Fri, 7 Aug 2026 07:07:22 +0200 Subject: [PATCH] feat(ssh): Add ability to send stdin input to `send_cmd` Extend the `send_cmd` function to support passing input to stdin when executing remote shell commands via SSH. Signed-off-by: Sven Sager --- src/revpicommander/ssh_tunneling/server.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/revpicommander/ssh_tunneling/server.py b/src/revpicommander/ssh_tunneling/server.py index 84d4573..b1448a2 100644 --- a/src/revpicommander/ssh_tunneling/server.py +++ b/src/revpicommander/ssh_tunneling/server.py @@ -187,12 +187,13 @@ class SSHLocalTunnel: except Exception: return True - def send_cmd(self, cmd: str, timeout: float = None) -> Union[Tuple[str, str, int], Tuple[None, None, None]]: + def send_cmd(self, cmd: str, timeout: float = None, stdin: str = None) -> Union[Tuple[str, str, int], Tuple[None, None, None]]: """ Send simple command to ssh host. :param cmd: Shell command to execute on remote host :param timeout: Timeout for execution + :param stdin: Send this string to stdin :return: Tuple with stdout, stderr, exit status """ if not self.connected: @@ -200,7 +201,7 @@ class SSHLocalTunnel: # Running async command from sync context async def _exec(): - result = await self._conn.run(cmd, timeout=timeout) + result = await self._conn.run(cmd, timeout=timeout, input=stdin) return result.stdout, result.stderr, result.exit_status try: