const { Client } = require('ssh2'); const conn = new Client(); conn.on('ready', () => { conn.exec('grep -c "add-btn\|累加" /www/huishou/dist/build/h5/assets/index-Cz9tJ-qu.js', (err, stream) => { if (err) { console.log('ERR:', err); } else { stream.on('data', (d) => console.log('index-Cz9tJ-qu.js中累加相关代码数量:', d.toString())); } stream.on('close', () => { conn.exec('grep -c "add-btn\|累加" /www/huishou/dist/build/h5/assets/pages-weigh-weigh*.js', (err2, stream2) => { if (err2) { console.log('ERR2:', err2); } else { stream2.on('data', (d2) => console.log('weigh页面JS中累加相关代码数量:', d2.toString())); } stream2.on('close', () => conn.end()); }); }); }); }); conn.connect({ host: 'hs.yifenbao.cn', port: 22, username: 'root', password: 'Torch1112' });