import paramiko

client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('152.136.232.83', port=22, username='root', password='Jianhua105', timeout=10)

def run(cmd):
    print(f"\n>>> {cmd[:120]}")
    stdin, stdout, stderr = client.exec_command(cmd, timeout=15)
    out = stdout.read().decode('utf-8', errors='replace').strip()
    err = stderr.read().decode('utf-8', errors='replace').strip()
    if out: print(out[-800:])
    if err: print(f"ERR: {err[-200:]}")
    return out

# Check loadSysConfig function
run("grep -n -A 10 'function loadSysConfig\\|loadSysConfig' /www/wwwroot/zhinengtiapp/index.js | head -20")

# Check the path it reads from
run("grep -n 'sysConfig.json\\|data/' /www/wwwroot/zhinengtiapp/index.js | head -10")

# Test loadSysConfig directly
run("""node -e "const path=require('path');const fs=require('fs');const p=path.join('/www/wwwroot/zhinengtiapp','data','sysConfig.json');console.log('path:',p);try{const d=fs.readFileSync(p,'utf8');console.log('data:',d);}catch(e){console.log('err:',e.message);}" """)

client.close()
