const { RemoteTerminal } = require('./remote_exec'); async function main() { const term = new RemoteTerminal('wss://soc-tester-9b6540e2d4ed.hosted.ghaymah.systems/ws'); await term.connect(); console.log('Testing ttyd with -I flag...'); await term.exec('printf "

HELLO SOC

" > /tmp/soc.html'); // Run ttyd in background with nohup and redirect await term.exec('nohup ttyd -p 7682 -I /tmp/soc.html -W bash > /tmp/ttyd_7682.log 2>&1 &'); await new Promise(r => setTimeout(r, 2000)); const log = await term.exec('cat /tmp/ttyd_7682.log'); console.log('Log:\n', log.output); const ps = await term.exec('ps aux | grep 7682'); console.log('Process:\n', ps.output); const wgetRes = await term.exec('wget -qO- http://localhost:7682/'); console.log('Wget response:\n', wgetRes.output); await term.exec('pkill -f "ttyd -p 7682" || true'); term.close(); } main().catch(console.error);