I want to use paramiko client with get_pty=False option. Do we have a way to send interrupt signal? I got some idea like to use client.close() but I am more interested to know why sending "\0x03"
fails with get_pty=False
.
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
connection_param= {'hostname': '192.168.255.1',
'username': 'username',
'password': 'password',
'port': '22',
'timeout': 15,
'key_filename': None,
'pkey': None}
client.connect(**connection_param)
stdin, stdout, stderr = client.exec_command("tail -f /tmp/test.log", bufsize=-1, timeout=None, get_pty=True)
time.sleep(1)
print(stdin.channel.exit_status_ready()) # False
stdin.write("\x03".encode())
stdin.channel.close()
print(stdout.read().decode(errors='ignore')) # File output
print(stdin.channel.exit_status_ready()) # True
stdin, stdout, stderr = client.exec_command("tail -f /tmp/test.log", bufsize=-1, timeout=None, get_pty=False)
time.sleep(1)
print(stdin.channel.exit_status_ready()) # False
stdin.channel.close() # hangs in next step for stdin.write("\x03".encode())
print(stdout.read().decode(errors='ignore')) # File output
print(stdin.channel.exit_status_ready()) # True
Do we have any other way to send interrupt signal using stdin.write()
for get_pty=False
.