#!/usr/bin/env python3 from pathlib import Path import sys ROOT = Path(r"c:\laragon\www\light-otantik-nux") sys.path.insert(0, str(ROOT / "scripts")) from deploy_remote import connect, sudo # noqa: E402 script = r''' python3 - <<'PY' from pathlib import Path import subprocess env={} for line in Path("/root/woyla.env").read_text().splitlines(): if "=" in line: k,v=line.split("=",1); env[k]=v def q(sql): print(subprocess.check_output(["mysql","-N","-u","nuxbill","-p"+env["DB_PASS"],"phpnuxbill","-e",sql], text=True, stderr=subprocess.STDOUT)) q("SELECT id,username,password,phonenumber,status,service_type FROM tbl_customers ORDER BY id DESC LIMIT 5") q("SELECT id,customer_id,username,namebp,expiration,time,status FROM tbl_user_recharges ORDER BY id DESC LIMIT 5") PY ''' client = connect() sftp = client.open_sftp() with sftp.file("/tmp/chk_cust.sh","w") as f: f.write(script.replace("\r\n","\n")) sftp.close() code,out = sudo(client,"bash /tmp/chk_cust.sh", timeout=20) print(out) client.close()