26 lines
921 B
Python
26 lines
921 B
Python
import paramiko
|
|
import sys
|
|
import io
|
|
|
|
if sys.platform == 'win32':
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8', errors='replace')
|
|
sys.stderr = io.TextIOWrapper(sys.stderr.buffer, encoding='utf-8', errors='replace')
|
|
|
|
client = paramiko.SSHClient()
|
|
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
|
client.connect('161.97.93.156', username='carlos', password='Innova1978+*?', timeout=10)
|
|
|
|
stdin, stdout, stderr = client.exec_command("docker ps --filter 'name=tayk' --format '{{.Names}}'")
|
|
container_name = stdout.read().decode('utf-8').strip()
|
|
print(f"Container: {container_name}")
|
|
|
|
stdin, stdout, stderr = client.exec_command(f"docker logs {container_name} --tail 60")
|
|
out_text = stdout.read().decode('utf-8', errors='replace')
|
|
err_text = stderr.read().decode('utf-8', errors='replace')
|
|
print("=== STDOUT ===")
|
|
print(out_text)
|
|
print("=== STDERR ===")
|
|
print(err_text)
|
|
|
|
client.close()
|