import paramiko
import sys

HOST = "135.125.102.180"
USER = "ubuntu"
PASS = "BotPascal2026!"

def main():
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(HOST, username=USER, password=PASS)
        
        print("Testing Scan Script (Limit 3)...")
        # Run as www-data to match web environment if possible, or just ubuntu to test logic
        # Running as ubuntu
        stdin, stdout, stderr = ssh.exec_command("php /var/www/html/repondeur_mail_grok/scripts/scan.php 3")
        out = stdout.read().decode()
        err = stderr.read().decode()
        
        print("STDOUT:", out)
        if err:
            print("STDERR:", err)
            
        ssh.close()
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()
