import paramiko

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"
REMOTE_LOG = "/var/www/html/repondeur_mail_grok/data/logs/scan_launch.log"

def main():
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(HOST, username=USER, password=PASS)
        
        print(f"🔍 Reading {REMOTE_LOG}...")
        stdin, stdout, stderr = ssh.exec_command(f"cat {REMOTE_LOG}")
        out = stdout.read().decode()
        err = stderr.read().decode()
        
        if out:
            print("--- LOG CONTENT ---")
            print(out)
        else:
            print("(Log file is empty or missing)")
            
        if err:
            print("--- STDERR ---")
            print(err)
        
        ssh.close()
    except Exception as e:
        print(f"❌ Error: {e}")

if __name__ == "__main__":
    main()
