import paramiko
import sys
import os
import time

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, banner_timeout=30)
        
        print("--- RUNNING SCAN.PHP (Limit 20) ---")
        stdin, stdout, stderr = ssh.exec_command("php /var/www/html/repondeur_mail_grok/scripts/scan.php 30")
        out = stdout.read().decode()
        err = stderr.read().decode()
        print(out)
        if err:
            print(f"Error: {err}")
            
        print("--- CHECKING QUEUE FOR WORDPRESS ---")
        stdin, stdout, stderr = ssh.exec_command("grep -i 'wordpress' /var/www/html/repondeur_mail_grok/data/queue.csv | head -n 5")
        print(stdout.read().decode())
        
        ssh.close()
    except Exception as e:
        print(f"Error: {e}")

if __name__ == "__main__":
    main()
