#!/usr/bin/env python3 import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parent)) import vps_ssh code, out = vps_ssh.run( r"""python3 - <<'PY' import re, subprocess t=open('/var/www/wifi-otantik/config.php').read() def g(k): m=re.search(r"\$"+k+r"\s*=\s*['\"]([^'\"]+)", t) return m.group(1) if m else '' host=g('db_host') or 'localhost' user=g('db_user'); pw=g('db_pass'); name=g('db_name') sql="SELECT id,name,slug,owner_id,ip_address FROM tbl_routers" r=subprocess.run(['mysql','-h',host,'-u',user,f'-p{pw}',name,'-N','-e',sql],capture_output=True,text=True) print(r.stdout) print(r.stderr.replace(pw,''), file=__import__('sys').stderr) raise SystemExit(r.returncode) PY""" ) print("code", code) print(out)