const { Client } = require('ssh2'); const conn = new Client(); conn.on('ready', () => { conn.exec('grep -o "pages-weigh-weigh[^"]*" /www/huishou/dist/build/h5/index.html', (err, stream) => { if (err) { console.log('ERR:', err); } else { stream.on('data', (d) => console.log('index.html引用的weigh文件:', d.toString())); } stream.on('close', () => { conn.exec('ls -la /www/huishou/dist/build/h5/assets/pages-weigh-weigh*.js | head -5', (err2, stream2) => { if (err2) { console.log('ERR2:', err2); } else { stream2.on('data', (d2) => console.log('存在的weigh文件:', d2.toString())); } stream2.on('close', () => conn.end()); }); }); }); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });